Simulink Port Dimensions Error
Show older comments
Hello everyone, new to Simulink. I have constant A (dimension is 7*7) multiplied by T (dimension is 1). I also have constant block B (size is 7*2) multiplied by an input block Y (dimensions is 2). I am using matrix multiplied for A*T and for B*Y. Equation therefore is M = A*T + B*Y. The using sum block to add them and output is M. The error is “Error in port widths or dimensions. Invalid dimension has been specified for input pot1” any help would be appreciated and even rules on setting the correct port dimensions would be appreciated.
Answers (1)
M = A.*T + B*Y %
7 Comments
A = randi([0 7],7,7)
T = randi(1);
B = randi([0 7],7,2)
Y = randi([0 2],2)
M1 = A*T %
M2 = B*Y %
M = [M1,M2] % try this instead
M = A*T + B.*Y % this operation is not possible
Learning
on 22 Nov 2022
No, you can change the matrix Y to desired size as
A = randi([0 7],7,7);
T = randi(1);
B = randi([0 7],7,2);
Y = randi([0 2],2,7); % change the size of Y (by zero padding)
M1 = A*T ; %
M2 = B*Y ; %
% M = [M1,M2]; % try this instead
M = A*T + B*Y %
OR use Matrix concatenator and selector blocks in simulink to include them as
M = [M1,M2];
Learning
on 22 Nov 2022
VBBV
on 22 Nov 2022
7x7, because the resulting size of M is 7x7
Learning
on 22 Nov 2022
Change the size of array Y from 2 x1 to 2 x7 as below
A = randi([0 7],7,7);
T = randi(1);
B = randi([0 7],7,2);
Y = randi([0 2],2,1) % change the size of Y (by zero padding)
Y = [Y(1) 0 0 0 0 0 0;Y(2) 0 0 0 0 0 0] % change it 2 x 7 by adding zeros
M = A*T + B*Y %
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!