I have a problem with simulink because when run the program:
古いコメントを表示

Error in port widths or dimensions. Invalid dimension has been specified for input port 5 of 'Model_MGDL/Subsystem/Sum'
採用された回答
その他の回答 (6 件)
Walter Roberson
2017 年 2 月 23 日
0 投票
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 件のコメント
Olivia Mendoza
2017 年 2 月 23 日
Olivia Mendoza
2017 年 2 月 23 日
Walter Roberson
2017 年 2 月 23 日
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?
Olivia Mendoza
2017 年 2 月 24 日
0 投票
1 件のコメント
Walter Roberson
2017 年 2 月 24 日
Please attach this model.
Olivia Mendoza
2017 年 2 月 24 日
0 投票
3 件のコメント
Walter Roberson
2017 年 2 月 24 日
In Subsystem3, input #1 is C, an 8 x 8 matrix. You pass that matrix to several Fcn blocks. Fcn1 for example is coded as -36*u(1) . That is a problem because u is not a scalar or vector, and "General Expression blocks" only permit scalar or vector inputs. You either need to switch to MATLAB Function Block for those, or you need to use a reshape to reshape the 8 x 8 into a vector.
When I look at the subsystem, I see that you only ever use u(1) of the 8x8 blocks. That leads me to wonder why you are sending the entire block in, instead of selecting only the one value and passing that in?
Olivia Mendoza
2017 年 2 月 25 日
Walter Roberson
2017 年 2 月 26 日
You may wish to recode as MATLAB Function Blocks
function y = fcn(u)
y = -36*u(1,1);
end
and the like.
Olivia Mendoza
2017 年 2 月 27 日
0 投票
1 件のコメント
Walter Roberson
2017 年 2 月 27 日
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.
Olivia Mendoza
2017 年 2 月 27 日
0 投票
1 件のコメント
Walter Roberson
2017 年 2 月 27 日
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.
Olivia Mendoza
2017 年 2 月 27 日
0 投票
1 件のコメント
Walter Roberson
2017 年 2 月 28 日
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.
カテゴリ
ヘルプ センター および File Exchange で Event Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


