Почему я получаю слишком много выходных аргументов в App Designer? - PullRequest
0 голосов
/ 23 октября 2019

Я получаю сообщение об ошибке в строке 122:

Ошибка Matlab слишком много выходных аргументов

Код:


     % Properties that correspond to app components
     properties (Access = public)
         UIFigure                      matlab.ui.Figure
         VoltageinputLabel             matlab.ui.control.Label
         ResistanceLabel               matlab.ui.control.Label
         InductanceLabel_2             matlab.ui.control.Label
         CapacitanceLabel_2            matlab.ui.control.Label
         timeLabel_2                   matlab.ui.control.Label
         vo                            matlab.ui.control.NumericEditField
         re                            matlab.ui.control.NumericEditField
         ca                            matlab.ui.control.NumericEditField
         in                            matlab.ui.control.NumericEditField
         time                          matlab.ui.control.NumericEditField
         CalculateButton               matlab.ui.control.Button
         ResistorVoltageCurrentLabel   matlab.ui.control.Label
         vrout                         matlab.ui.control.Label
         crout                         matlab.ui.control.Label
         curcuitdiagramLabel           matlab.ui.control.Label
         Image                         matlab.ui.control.Image
         ElementsinParallelDropDownLabel  matlab.ui.control.Label
         ElementsinParallelDropDown    matlab.ui.control.DropDown
         CapacitorVoltageCurrentLabel  matlab.ui.control.Label
         InductorVoltageCurrentLabel   matlab.ui.control.Label
         vcout                         matlab.ui.control.Label
         ccout                         matlab.ui.control.Label
         viout                         matlab.ui.control.Label
         ciout                         matlab.ui.control.Label
     end

     % Callbacks that handle component events
     methods (Access = private)

         % Value changed function: vo
         function voValueChanged(app, event)
             value = app.vo.Value;
          %% app.vcout.Text = int2str(value);
          %% app.vrout.Text = int2str(value);
          %% app.viout.Text = int2str(value);
         end

         % Value changed function: ElementsinParallelDropDown
         function ElementsinParallelDropDownValueChanged(app, event)
             value = app.ElementsinParallelDropDown.Value;
             switch value
                 case 'NONE'
                     app.Image.ImageSource = 'none.jpeg';

                     app.vo.Editable = 'off';
                     app.ResistanceLabel.Enable = 'off';
                     app.re.Enable = 'off';
                     app.CapacitanceLabel_2.Enable = 'off';
                     app.ca.Enable = 'off';
                     app.InductanceLabel_2.Enable = 'off';
                     app.in.Enable = 'off';
                     app.time.Editable = 'off';


                 case 'Resistors and Inductor '
                     app.Image.ImageSource = 're&in.jpeg';

                     app.vo.Editable = 'on';
                     app.ResistanceLabel.Enable = 'on';
                     app.re.Enable = 'on';
                     app.CapacitanceLabel_2.Enable = 'off';
                     app.ca.Enable = 'off';
                     app.InductanceLabel_2.Enable = 'on';
                     app.in.Enable = 'on';
                     app.time.Editable = 'on';

                 case 'Resistor and Capasitor'
                     app.Image.ImageSource = 'ca&re.jpeg';

                     app.vo.Editable = 'on';
                     app.ResistanceLabel.Enable = 'on';
                     app.re.Enable = 'on';
                     app.CapacitanceLabel_2.Enable = 'on';
                     app.ca.Enable = 'on';
                     app.InductanceLabel_2.Enable = 'off';
                     app.in.Enable = 'off';
                     app.time.Editable = 'on';

                 case 'Capasitor ans Inductor '
                     app.Image.ImageSource = 'ca&in.jpeg';

                     app.vo.Editable = 'on';
                     app.ResistanceLabel.Enable = 'off';
                     app.re.Enable = 'off';
                     app.CapacitanceLabel_2.Enable = 'on';
                     app.ca.Enable = 'on';
                     app.InductanceLabel_2.Enable = 'on';
                     app.in.Enable = 'on';
                     app.time.Editable = 'on';

                 case 'All elements '
                     app.Image.ImageSource = 'all.jpeg';
                     %% enabling 
                     app.vo.Editable = 'on';
                     app.ResistanceLabel.Enable = 'on';
                     app.re.Enable = 'on';
                     app.CapacitanceLabel_2.Enable = 'on';
                     app.ca.Enable = 'on';
                     app.InductanceLabel_2.Enable = 'on';
                     app.in.Enable = 'on';
                     app.time.Editable = 'on';



             end
         end

         % Button pushed function: CalculateButton
         function CalculateButtonPushed(app, event)
          value =  app.ElementsinParallelDropDown.Value;

          switch value
                 case 'NONE'


                 case 'Resistors and Inductor '
                    vin = app.voValueChanged.Value ; 
                    rin = app.reValueChanged.Value ; 
                    L  = app.inValueChanged.Value ; 
                    t = app.timeValueChanged.Value;

                    iresres = vin / rin ;
                    iresind = (vin * t)/ L ; 

                    app.crout.Text = int2str(iresres);
                    app.ciout.Text = int2str(iresind);



                 case 'Resistor and Capasitor'


                 case 'Capasitor ans Inductor '


                 case 'All elements '


             end
         end

         % Value changed function: re
         function reValueChanged(app, event)
             value = app.re.Value;

         end

         % Value changed function: ca
         function caValueChanged(app, event)
             value = app.ca.Value;

         end

         % Value changed function: in
         function inValueChanged(app, event)
             value = app.in.Value;

         end

         % Value changed function: time
         function timeValueChanged(app, event)
             value = app.time.Value;

         end
     end

     % Component initialization
     methods (Access = private)

         % Create UIFigure and components
         function createComponents(app)

             % Create UIFigure and hide until all components are created
             app.UIFigure = uifigure('Visible', 'off');
             app.UIFigure.Position = [100 100 764 631];
             app.UIFigure.Name = 'UI Figure';

             % Create VoltageinputLabel
             app.VoltageinputLabel = uilabel(app.UIFigure);
             app.VoltageinputLabel.Position = [105 378 75 22];
             app.VoltageinputLabel.Text = 'Voltage input';

             % Create ResistanceLabel
             app.ResistanceLabel = uilabel(app.UIFigure);
             app.ResistanceLabel.Enable = 'off';
             app.ResistanceLabel.Position = [109 316 68 22];
             app.ResistanceLabel.Text = 'Resistance ';

             % Create InductanceLabel_2
             app.InductanceLabel_2 = uilabel(app.UIFigure);
             app.InductanceLabel_2.Enable = 'off';
             app.InductanceLabel_2.Position = [109 208 68 22];
             app.InductanceLabel_2.Text = 'Inductance ';

             % Create CapacitanceLabel_2
             app.CapacitanceLabel_2 = uilabel(app.UIFigure);
             app.CapacitanceLabel_2.Enable = 'off';
             app.CapacitanceLabel_2.Position = [106 264 76 22];
             app.CapacitanceLabel_2.Text = 'Capacitance ';

             % Create timeLabel_2
             app.timeLabel_2 = uilabel(app.UIFigure);
             app.timeLabel_2.Position = [128 153 32 22];
             app.timeLabel_2.Text = 'time ';

             % Create vo
             app.vo = uieditfield(app.UIFigure, 'numeric');
             app.vo.ValueChangedFcn = createCallbackFcn(app, @voValueChanged, true);
             app.vo.Editable = 'off';
             app.vo.Position = [92 349 100 22];

             % Create re
             app.re = uieditfield(app.UIFigure, 'numeric');
             app.re.ValueChangedFcn = createCallbackFcn(app, @reValueChanged, true);
             app.re.Enable = 'off';
             app.re.Position = [92 295 100 22];

             % Create ca
             app.ca = uieditfield(app.UIFigure, 'numeric');
             app.ca.ValueChangedFcn = createCallbackFcn(app, @caValueChanged, true);
             app.ca.Enable = 'off';
             app.ca.Position = [92 243 100 22];

             % Create in
             app.in = uieditfield(app.UIFigure, 'numeric');
             app.in.ValueChangedFcn = createCallbackFcn(app, @inValueChanged, true);
             app.in.Enable = 'off';
             app.in.Position = [92 187 100 22];

             % Create time
             app.time = uieditfield(app.UIFigure, 'numeric');
             app.time.ValueChangedFcn = createCallbackFcn(app, @timeValueChanged, true);
             app.time.Editable = 'off';
             app.time.Position = [92 132 100 22];

             % Create CalculateButton
             app.CalculateButton = uibutton(app.UIFigure, 'push');
             app.CalculateButton.ButtonPushedFcn = createCallbackFcn(app, @CalculateButtonPushed, true);
             app.CalculateButton.Icon = 'calc.png';
             app.CalculateButton.IconAlignment = 'right';
             app.CalculateButton.BackgroundColor = [1 1 1];
             app.CalculateButton.Position = [370 78 112 47];
             app.CalculateButton.Text = 'Calculate';

             % Create ResistorVoltageCurrentLabel
             app.ResistorVoltageCurrentLabel = uilabel(app.UIFigure);
             app.ResistorVoltageCurrentLabel.Position = [550 318 63 84];
             app.ResistorVoltageCurrentLabel.Text = {'Resistor  '; ''; ' - Voltage :'; ''; ' - Current :'; ''; ''};

             % Create vrout
             app.vrout = uilabel(app.UIFigure);
             app.vrout.Position = [636 357 25 22];
             app.vrout.Text = '~';

             % Create crout
             app.crout = uilabel(app.UIFigure);
             app.crout.Position = [636 328 25 22];
             app.crout.Text = '~';

             % Create curcuitdiagramLabel
             app.curcuitdiagramLabel = uilabel(app.UIFigure);
             app.curcuitdiagramLabel.HorizontalAlignment = 'center';
             app.curcuitdiagramLabel.FontSize = 15;
             app.curcuitdiagramLabel.Position = [456 572 119 22];
             app.curcuitdiagramLabel.Text = 'curcuit diagram';

             % Create Image
             app.Image = uiimage(app.UIFigure);
             app.Image.Position = [326 386 380 223];
             app.Image.ImageSource = 'none.jpeg';

             % Create ElementsinParallelDropDownLabel
             app.ElementsinParallelDropDownLabel = uilabel(app.UIFigure);
             app.ElementsinParallelDropDownLabel.HorizontalAlignment = 'right';
             app.ElementsinParallelDropDownLabel.Position = [85 572 115 22];
             app.ElementsinParallelDropDownLabel.Text = 'Elements in Parallel ';

             % Create ElementsinParallelDropDown
             app.ElementsinParallelDropDown = uidropdown(app.UIFigure);
             app.ElementsinParallelDropDown.Items = {'NONE', 'Resistors and Inductor ', 'Resistor and Capasitor', 'Capasitor ans Inductor ', 'All elements '};
             app.ElementsinParallelDropDown.ValueChangedFcn = createCallbackFcn(app, @ElementsinParallelDropDownValueChanged, true);
             app.ElementsinParallelDropDown.Position = [45 544 196 22];
             app.ElementsinParallelDropDown.Value = 'NONE';

             % Create CapacitorVoltageCurrentLabel
             app.CapacitorVoltageCurrentLabel = uilabel(app.UIFigure);
             app.CapacitorVoltageCurrentLabel.Position = [550 202 63 84];
             app.CapacitorVoltageCurrentLabel.Text = {'Capacitor'; ''; ' - Voltage :'; ''; ' - Current :'; ''; ''};

             % Create InductorVoltageCurrentLabel
             app.InductorVoltageCurrentLabel = uilabel(app.UIFigure);
             app.InductorVoltageCurrentLabel.Position = [550 101 63 84];
             app.InductorVoltageCurrentLabel.Text = {'Inductor'; ''; ' - Voltage :'; ''; ' - Current :'; ''; ''};

             % Create vcout
             app.vcout = uilabel(app.UIFigure);
             app.vcout.Position = [636 243 25 22];
             app.vcout.Text = '~';

             % Create ccout
             app.ccout = uilabel(app.UIFigure);
             app.ccout.Position = [636 208 25 22];
             app.ccout.Text = '~';

             % Create viout
             app.viout = uilabel(app.UIFigure);
             app.viout.Position = [636 135 25 22];
             app.viout.Text = '~';

             % Create ciout
             app.ciout = uilabel(app.UIFigure);
             app.ciout.Position = [636 111 25 22];
             app.ciout.Text = '~';

             % Show the figure after all components are created
             app.UIFigure.Visible = 'on';
         end
     end

     % App creation and deletion
     methods (Access = public)

         % Construct app
         function app = app1

             % Create UIFigure and components
             createComponents(app)

             % Register the app with App Designer
             registerApp(app, app.UIFigure)

             if nargout == 0
                 clear app
             end
         end

         % Code that executes before app deletion
         function delete(app)

             % Delete UIFigure when app is deleted
             delete(app.UIFigure)
         end
     end
 end ```


Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...