Simulink doubt -not have enough information to determine output sizes for this block

Please find attached the simulink diagram. The code in the main function block is as follows :
function [xdot,xcapdot,dbar_dot,xdotr,ut] =fcn(x,xcap,dbar,xr,A,B,C,L,Kp,Kr,r,d,tau)
y=C*x
ycap=C*xcap
dbar_dot=((B'/(B'*B))*L*(y-ycap))/(tau)
xdotr=r-y
k=Kp*xcap
uf=-(k+Kr*xr)
ut=-uf-dbar
xdot=(A*x+B*ut+B*d)
xcapdot=(A*xcap)+(B*uf)+(L*(y-ycap));
On running this simulink program, I am getting the following error
Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
Inner matrix dimensions must agree. Function 'MATLAB Function' (#35.196.200), line 16, column 11: "B*ut"
Function 'MATLAB Function' (#29.235.239), line 18, column 19:
"B*uf"
Errors occurred during parsing of MATLAB function 'MATLAB Function'
The problem lies in the fact that simulink (Refer to attached pic) is considering x and xcap and xdot as 1*1 but they are actually (3*1). How should I correct this
What error am I doing? How should I correct them.

댓글 수: 4

Reading the error, the first part clearly says
Undefined function or variable 'uf'
Where is this variable? It is neither computed inside the function nor an input to the function. It is in line 8 of the code pasted above.
Also, I don't think you have pasted the full function code. The second part of the error is pointing to line 12 but your code has only 8 lines?
Actually I have given one line space. after every line of code for clarity. I have edited it above now. It is a full function code
The problem lies in the fact that simulink (Refer to attached pic) is considering x and xcap and xdot as 1*1 but they are actually (3*1). How should I correct this
One thing you can try is to explicitly specify the sizes for these input variables in MATLAB function block editor's Edit Data option. Take a look at the documentation example here to see how to do this and then set the size appropriately.

댓글을 달려면 로그인하십시오.

답변 (1개)

Souarv De
Souarv De 2019년 9월 26일
Assign these values at the starting of your function
x = zeros(3,1);
xcap = zeros(3,1);
xdot = zeros(3,1);

댓글 수: 1

what is the correct way for assigning?
For example the output data is a vector [x1;x2], but the data are written to a file as [x1 x2].
If the program read out the file with
value = sscanf(file, '%g', [1,2])
and then makes a following assignment:
x1 = value(1,1)
x2 = value(1,2)
value=double([x1;x2])
I got the same error massage.
If the program makes an assignmnet as a scalar
x1 = value(1,1)
x2 = value(1,2)
value=0;
there is no error massage. But schould value be declared as a scalar?

댓글을 달려면 로그인하십시오.

카테고리

태그

질문:

2017년 7월 28일

댓글:

2020년 1월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by