Invalid setting for parameter 'Gain'












1















I am trying to create a simple controller, but keep receiving an error for the gain block stating that there is an undefined variable 'u'. I do not understand Simulink well and I am just trying to replicate an old homework problem right now. The code I have here was provided as a solution, but I still receive the error when I try to run it. Any insights as to what might be going on?



I= 10; Wl= 5; k= 2; J= 1; 
%set initial conditions
thetaIC= 0; phiIC= 0; x0= zeros(4,1);
%fix theta= 0, check output
[xe, ue]= trim('Ex3_System',x0,0,x0,1)
[A,B,~,~]= linmod('Ex3_System', xe, ue)
%choose your desired poles
p= linspace(-1.2,-1.5,4)
%recall the minus sign
K= -acker(A,B,p)
%perturb initial condition
thetaIC= deg2rad(5);
sim('Ex3_Controller');


enter image description hereenter image description here




Invalid setting in 'Ex3_Controller/Gain' for parameter 'Gain'. Caused
by:
Error using hw12 (line 57)
Error evaluating parameter 'Gain' in 'Ex3_Controller/Gain'
Error using hw12 (line 57)
Undefined function or variable 'u'.
Error using hw12 (line 57)
Variable 'u' does not exist.
Suggested Actions:
• Load a file into 'Base Workspace'. - Fix
• Create a new variable. - Fix




Update: After removing the u term from the gain block, I received a different error:




Error using hw12 (line 57)
Error in port widths or dimensions. Output port 1 of 'Ex3_Controller/Gain' is a one dimensional vector with 4 elements.
Error using hw12 (line 57)
Error in port widths or dimensions. Input port 1 of 'Ex3_Controller/Model1' is a one dimensional vector with 1 elements.











share|improve this question





























    1















    I am trying to create a simple controller, but keep receiving an error for the gain block stating that there is an undefined variable 'u'. I do not understand Simulink well and I am just trying to replicate an old homework problem right now. The code I have here was provided as a solution, but I still receive the error when I try to run it. Any insights as to what might be going on?



    I= 10; Wl= 5; k= 2; J= 1; 
    %set initial conditions
    thetaIC= 0; phiIC= 0; x0= zeros(4,1);
    %fix theta= 0, check output
    [xe, ue]= trim('Ex3_System',x0,0,x0,1)
    [A,B,~,~]= linmod('Ex3_System', xe, ue)
    %choose your desired poles
    p= linspace(-1.2,-1.5,4)
    %recall the minus sign
    K= -acker(A,B,p)
    %perturb initial condition
    thetaIC= deg2rad(5);
    sim('Ex3_Controller');


    enter image description hereenter image description here




    Invalid setting in 'Ex3_Controller/Gain' for parameter 'Gain'. Caused
    by:
    Error using hw12 (line 57)
    Error evaluating parameter 'Gain' in 'Ex3_Controller/Gain'
    Error using hw12 (line 57)
    Undefined function or variable 'u'.
    Error using hw12 (line 57)
    Variable 'u' does not exist.
    Suggested Actions:
    • Load a file into 'Base Workspace'. - Fix
    • Create a new variable. - Fix




    Update: After removing the u term from the gain block, I received a different error:




    Error using hw12 (line 57)
    Error in port widths or dimensions. Output port 1 of 'Ex3_Controller/Gain' is a one dimensional vector with 4 elements.
    Error using hw12 (line 57)
    Error in port widths or dimensions. Input port 1 of 'Ex3_Controller/Model1' is a one dimensional vector with 1 elements.











    share|improve this question



























      1












      1








      1








      I am trying to create a simple controller, but keep receiving an error for the gain block stating that there is an undefined variable 'u'. I do not understand Simulink well and I am just trying to replicate an old homework problem right now. The code I have here was provided as a solution, but I still receive the error when I try to run it. Any insights as to what might be going on?



      I= 10; Wl= 5; k= 2; J= 1; 
      %set initial conditions
      thetaIC= 0; phiIC= 0; x0= zeros(4,1);
      %fix theta= 0, check output
      [xe, ue]= trim('Ex3_System',x0,0,x0,1)
      [A,B,~,~]= linmod('Ex3_System', xe, ue)
      %choose your desired poles
      p= linspace(-1.2,-1.5,4)
      %recall the minus sign
      K= -acker(A,B,p)
      %perturb initial condition
      thetaIC= deg2rad(5);
      sim('Ex3_Controller');


      enter image description hereenter image description here




      Invalid setting in 'Ex3_Controller/Gain' for parameter 'Gain'. Caused
      by:
      Error using hw12 (line 57)
      Error evaluating parameter 'Gain' in 'Ex3_Controller/Gain'
      Error using hw12 (line 57)
      Undefined function or variable 'u'.
      Error using hw12 (line 57)
      Variable 'u' does not exist.
      Suggested Actions:
      • Load a file into 'Base Workspace'. - Fix
      • Create a new variable. - Fix




      Update: After removing the u term from the gain block, I received a different error:




      Error using hw12 (line 57)
      Error in port widths or dimensions. Output port 1 of 'Ex3_Controller/Gain' is a one dimensional vector with 4 elements.
      Error using hw12 (line 57)
      Error in port widths or dimensions. Input port 1 of 'Ex3_Controller/Model1' is a one dimensional vector with 1 elements.











      share|improve this question
















      I am trying to create a simple controller, but keep receiving an error for the gain block stating that there is an undefined variable 'u'. I do not understand Simulink well and I am just trying to replicate an old homework problem right now. The code I have here was provided as a solution, but I still receive the error when I try to run it. Any insights as to what might be going on?



      I= 10; Wl= 5; k= 2; J= 1; 
      %set initial conditions
      thetaIC= 0; phiIC= 0; x0= zeros(4,1);
      %fix theta= 0, check output
      [xe, ue]= trim('Ex3_System',x0,0,x0,1)
      [A,B,~,~]= linmod('Ex3_System', xe, ue)
      %choose your desired poles
      p= linspace(-1.2,-1.5,4)
      %recall the minus sign
      K= -acker(A,B,p)
      %perturb initial condition
      thetaIC= deg2rad(5);
      sim('Ex3_Controller');


      enter image description hereenter image description here




      Invalid setting in 'Ex3_Controller/Gain' for parameter 'Gain'. Caused
      by:
      Error using hw12 (line 57)
      Error evaluating parameter 'Gain' in 'Ex3_Controller/Gain'
      Error using hw12 (line 57)
      Undefined function or variable 'u'.
      Error using hw12 (line 57)
      Variable 'u' does not exist.
      Suggested Actions:
      • Load a file into 'Base Workspace'. - Fix
      • Create a new variable. - Fix




      Update: After removing the u term from the gain block, I received a different error:




      Error using hw12 (line 57)
      Error in port widths or dimensions. Output port 1 of 'Ex3_Controller/Gain' is a one dimensional vector with 4 elements.
      Error using hw12 (line 57)
      Error in port widths or dimensions. Input port 1 of 'Ex3_Controller/Model1' is a one dimensional vector with 1 elements.








      simulink






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 28 '18 at 17:47







      RocketSocks22

















      asked Nov 28 '18 at 5:00









      RocketSocks22RocketSocks22

      8010




      8010
























          1 Answer
          1






          active

          oldest

          votes


















          2














          The Gain block takes the value of the input signal and multiplies it by the value of the gain. In your case the gain is K and that is all you need to put into the gain block (i.e. remove the *u, Simulink handles that for you.)



          Once that is done, the dimension error you are getting is because your controller requires u to be a scalar, but you are feeding a 4 element vector into it. You need to change the appropriate parameter of the Gain block so that it does a matrix multiplication, taking the 4-by-1 matrix K and (matrix) multiplying it with the 4 element "out" signal to produce a scalar.






          share|improve this answer


























          • Thank you for the response! After removing the *u from the gain block, I received a new error. I've uploaded the model of the system being used in the controller as well if this is any help, and also updated my question with the new error I'm receiving upon doing so

            – RocketSocks22
            Nov 28 '18 at 17:50











          • I figured out the issue. After removing the *u I needed to change the operation type to matrix multiplication. Upon doing so, the gain block automatically adds the *u, making it appear as if this was the original gain block. Thank you!

            – RocketSocks22
            Nov 30 '18 at 1:19











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53512434%2finvalid-setting-for-parameter-gain%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          The Gain block takes the value of the input signal and multiplies it by the value of the gain. In your case the gain is K and that is all you need to put into the gain block (i.e. remove the *u, Simulink handles that for you.)



          Once that is done, the dimension error you are getting is because your controller requires u to be a scalar, but you are feeding a 4 element vector into it. You need to change the appropriate parameter of the Gain block so that it does a matrix multiplication, taking the 4-by-1 matrix K and (matrix) multiplying it with the 4 element "out" signal to produce a scalar.






          share|improve this answer


























          • Thank you for the response! After removing the *u from the gain block, I received a new error. I've uploaded the model of the system being used in the controller as well if this is any help, and also updated my question with the new error I'm receiving upon doing so

            – RocketSocks22
            Nov 28 '18 at 17:50











          • I figured out the issue. After removing the *u I needed to change the operation type to matrix multiplication. Upon doing so, the gain block automatically adds the *u, making it appear as if this was the original gain block. Thank you!

            – RocketSocks22
            Nov 30 '18 at 1:19
















          2














          The Gain block takes the value of the input signal and multiplies it by the value of the gain. In your case the gain is K and that is all you need to put into the gain block (i.e. remove the *u, Simulink handles that for you.)



          Once that is done, the dimension error you are getting is because your controller requires u to be a scalar, but you are feeding a 4 element vector into it. You need to change the appropriate parameter of the Gain block so that it does a matrix multiplication, taking the 4-by-1 matrix K and (matrix) multiplying it with the 4 element "out" signal to produce a scalar.






          share|improve this answer


























          • Thank you for the response! After removing the *u from the gain block, I received a new error. I've uploaded the model of the system being used in the controller as well if this is any help, and also updated my question with the new error I'm receiving upon doing so

            – RocketSocks22
            Nov 28 '18 at 17:50











          • I figured out the issue. After removing the *u I needed to change the operation type to matrix multiplication. Upon doing so, the gain block automatically adds the *u, making it appear as if this was the original gain block. Thank you!

            – RocketSocks22
            Nov 30 '18 at 1:19














          2












          2








          2







          The Gain block takes the value of the input signal and multiplies it by the value of the gain. In your case the gain is K and that is all you need to put into the gain block (i.e. remove the *u, Simulink handles that for you.)



          Once that is done, the dimension error you are getting is because your controller requires u to be a scalar, but you are feeding a 4 element vector into it. You need to change the appropriate parameter of the Gain block so that it does a matrix multiplication, taking the 4-by-1 matrix K and (matrix) multiplying it with the 4 element "out" signal to produce a scalar.






          share|improve this answer















          The Gain block takes the value of the input signal and multiplies it by the value of the gain. In your case the gain is K and that is all you need to put into the gain block (i.e. remove the *u, Simulink handles that for you.)



          Once that is done, the dimension error you are getting is because your controller requires u to be a scalar, but you are feeding a 4 element vector into it. You need to change the appropriate parameter of the Gain block so that it does a matrix multiplication, taking the 4-by-1 matrix K and (matrix) multiplying it with the 4 element "out" signal to produce a scalar.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 28 '18 at 23:47

























          answered Nov 28 '18 at 16:13









          Phil GoddardPhil Goddard

          9,1771924




          9,1771924













          • Thank you for the response! After removing the *u from the gain block, I received a new error. I've uploaded the model of the system being used in the controller as well if this is any help, and also updated my question with the new error I'm receiving upon doing so

            – RocketSocks22
            Nov 28 '18 at 17:50











          • I figured out the issue. After removing the *u I needed to change the operation type to matrix multiplication. Upon doing so, the gain block automatically adds the *u, making it appear as if this was the original gain block. Thank you!

            – RocketSocks22
            Nov 30 '18 at 1:19



















          • Thank you for the response! After removing the *u from the gain block, I received a new error. I've uploaded the model of the system being used in the controller as well if this is any help, and also updated my question with the new error I'm receiving upon doing so

            – RocketSocks22
            Nov 28 '18 at 17:50











          • I figured out the issue. After removing the *u I needed to change the operation type to matrix multiplication. Upon doing so, the gain block automatically adds the *u, making it appear as if this was the original gain block. Thank you!

            – RocketSocks22
            Nov 30 '18 at 1:19

















          Thank you for the response! After removing the *u from the gain block, I received a new error. I've uploaded the model of the system being used in the controller as well if this is any help, and also updated my question with the new error I'm receiving upon doing so

          – RocketSocks22
          Nov 28 '18 at 17:50





          Thank you for the response! After removing the *u from the gain block, I received a new error. I've uploaded the model of the system being used in the controller as well if this is any help, and also updated my question with the new error I'm receiving upon doing so

          – RocketSocks22
          Nov 28 '18 at 17:50













          I figured out the issue. After removing the *u I needed to change the operation type to matrix multiplication. Upon doing so, the gain block automatically adds the *u, making it appear as if this was the original gain block. Thank you!

          – RocketSocks22
          Nov 30 '18 at 1:19





          I figured out the issue. After removing the *u I needed to change the operation type to matrix multiplication. Upon doing so, the gain block automatically adds the *u, making it appear as if this was the original gain block. Thank you!

          – RocketSocks22
          Nov 30 '18 at 1:19




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53512434%2finvalid-setting-for-parameter-gain%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

          Calculate evaluation metrics using cross_val_predict sklearn

          Insert data from modal to MySQL (multiple modal on website)