I have a problem with simulink because when run the program:

3 views (last 30 days)
Error in port widths or dimensions. Invalid dimension has been specified for input port 5 of 'Model_MGDL/Subsystem/Sum'
  1 Comment
Olivia Mendoza
Olivia Mendoza on 22 Feb 2017
Error in port widths or dimensions. Invalid dimension has been specified for input port 5 of 'Model_MGDL/Subsystem/Sum'.
Error in port widths or dimensions. Output port 1 of 'Model_MGDL/Subsystem/C' is a [8x8] matrix.

Sign in to comment.

Accepted Answer

Olivia Mendoza
Olivia Mendoza on 24 Feb 2017
Making corrections to the observations that made me, even so I have problems, my inputs are 8x1 and 8x8 and still I do not allow me to perform the correct process, which I still do wrong :(
  1 Comment
Walter Roberson
Walter Roberson on 24 Feb 2017
If you have an 8 x 1 input and an 8 x 8 input, then what is the desired result? Should each row of the 8 x 1 be replicated into 8 x 8 and that added to the 8 x 8 ? Simulink does not know to do that: if you want inputs to be replicated then you have to do that with a separate block.

Sign in to comment.

More Answers (6)

Walter Roberson
Walter Roberson on 23 Feb 2017
Your Constant block is 1 x 4. Your output of Add1 is 8 x 8. You are trying to add the two together with a Sum block. What output are you expecting?
  3 Comments
Olivia Mendoza
Olivia Mendoza on 23 Feb 2017
Is the mathematical model of a system of 4 degrees of freedom
Walter Roberson
Walter Roberson on 23 Feb 2017
Ignoring the Simulink portion of it for a moment: What is the mathematical formula for your desired outcome for adding a 1 x 4 vector to an 8 x 8 array.
For example, is your desired outcome to replicate the 1 x 4 vector once per row, taking [A B C D] to [A B C D A B C D], and then to replicate that 8 times, so you get
[A B C D A B C D
A B C D A B C D
A B C D A B C D
A B C D A B C D
A B C D A B C D
A B C D A B C D
A B C D A B C D
A B C D A B C D]
and add that to your 8 x 8 Matrix?
Or should the 1 x 4 be reshaped to 2 x 2, and then that replicated as needed:
A B A B A B A B
C D C D C D C D
A B A B A B A B
C D C D C D C D
A B A B A B A B
C D C D C D C D
A B A B A B A B
C D C D C D C D
and that should be added to the 8 x 8?
Or should it be be
A A A A A A A A
B B B B B B B B
C C C C C C C C
D D D D D D D D
A A A A A A A A
B B B B B B B B
C C C C C C C C
D D D D D D D D
added to the 8 x 8?
or something else?

Sign in to comment.


Olivia Mendoza
Olivia Mendoza on 24 Feb 2017
I tried with a simpler cycle and still do not do it, I do not know if I'm messing with the integrator or what it is

Olivia Mendoza
Olivia Mendoza on 24 Feb 2017
The simple model and the firts model
  3 Comments
Olivia Mendoza
Olivia Mendoza on 25 Feb 2017
I use fnc blocks because later I need to run the program with different values and that will make it easier to modify it, or block instead of fnc recommend me to replace it or how?
Walter Roberson
Walter Roberson on 26 Feb 2017
You may wish to recode as MATLAB Function Blocks
function y = fcn(u)
y = -36*u(1,1);
end
and the like.

Sign in to comment.


Olivia Mendoza
Olivia Mendoza on 27 Feb 2017
I made the arrays to u (1,1 |) in the matrix blocks and now it appears:
Error while parsing expression: 36*u(1,1) in 'Model_MGDL_P1/Subsystem/C/C/Subsystem/Subsystem3/Fcn1' token "," was found, where as ")" was expected
  1 Comment
Walter Roberson
Walter Roberson on 27 Feb 2017
You cannot use 2D subscripts in an arithmetic block. That is why I was talking about MATLAB Function Blocks: they can have general MATLAB code.

Sign in to comment.


Olivia Mendoza
Olivia Mendoza on 27 Feb 2017
Hi, i resolved my problem but i have a new problem with the model:
An error occurred while running the simulation and the simulation was terminated
Derivative of state '4' in block 'Model_MGDL/Subsystem/Integrator' at time 0.59593389906600114 is not finite. The simulation will be stopped. There may be a singularity in the solution. If not, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances
  1 Comment
Walter Roberson
Walter Roberson on 27 Feb 2017
Your Matrix Inversion is probably failing. Matrix inversion is fragile. At the very least you should consider using https://www.mathworks.com/help/dsp/ref/pseudoinverse.html
Probably reformulating as a matrix division instead of multiplying by inverse would be less fragile than what you have now, but pinv would be less fragile than that. You should also consider using a MATLAB Function Block in order to be able to use the \ operator if you are using discrete time instead of continuous time.

Sign in to comment.


Olivia Mendoza
Olivia Mendoza on 27 Feb 2017
I already considered other methods of inverse and sends me the same error
  1 Comment
Walter Roberson
Walter Roberson on 28 Feb 2017
Well, create a new Question for this and post the model there.
Note: to reply to what someone else has posted, click on "Comment on this Answer" instead of creating a new Answer.

Sign in to comment.

Categories

Find more on Programmatic Model Editing in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!