I'm having issues with a Simulink S-Function I've written, and keep getting the error message:
"Error in default port dimensions function of S-function 'LQR_Initial_System/LQR Implementation'. This function does not fully set the dimensions of output port 2"
Unfortunately, the S Function in question only has a single output port. The Simulink model explorer only recognises a single output port, as the pic "Model Ports.jpg" shows.
Could anyone offer any help please?
Thanks

댓글 수: 4

Fangjun Jiang
Fangjun Jiang 2018년 12월 3일
You have to show the S-function source code to debug the problem.
Sorry; I assumed it'd be with the model I uploaded.
I've tweaked the model somewhat since asking this question, however the problem still persists. Here is the source code:
function [Wheel_Force,Body_Force] = fcn(x1, x2, x3, x4, Kt, Ks, Cs,Ms,Mu,Alpha)
A = [0 0 -1 0; 0 0 1 -1; Kt/Mu (-Ks/Mu) (-Cs/Mu) Cs/Mu; 0 Ks/Ms Cs/Ms (-Cs/Ms)];
B = [0; 0; -1; 1];
R = (1/(Ms^2));
Q = [Alpha 0 0 0; 0 ((Ks^2)/(Ms^2)) ((Ks*Cs)/(Ms^2)) (-(Ks*Cs)/(Ms^2));...
0 ((Ks*Cs)/(Ms^2)) ((Cs^2)/(Ms^2)) (-(Cs^2)/(Ms^2)); 0 (-(Ks*Cs)/(Ms^2)) (-(Cs^2)/(Ms^2)) ((Cs^2)/(Ms^2))];
A_Trans = transpose(A);
R_Inverse = inverse(R);
B_Trans = transpose(B);
Coeff_Matrix = (A_Trans + A - (B*R_Inverse*B_Trans));
Coeff_Inverse = inverse(Coeff_Matrix);
P = (Q*-1)*Coeff_Inverse;
K = R_Inverse*B_Trans*P;
Wheel_Force = (-K(3)*x3);
Body_Force = (-K(4)*x4);
Liping
Liping 2018년 12월 19일
Can you help me to solve the same problem?
Error in default port dimensions function of S-function 'fangzhen22/Embedded MATLAB Function'. This function does not fully set the dimensions of output port 2
`]8JTX`TN$%ISGH(8)R4]15.jpg
Fangjun Jiang
Fangjun Jiang 2018년 12월 19일
Look at the .jpg file in the original question, find the similar place for your Embedded MATLAB Function block, change the "size" of "FS" from -1 to something else, likely 1 if your FS is a scalar.

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

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2018년 12월 3일

0 개 추천

This is not a Simulink S-function. It is a MATLAB Function block.
Anyway, as you've shown in your attached image, just explicitly specify the "size" for "F1". For example, it seems that the size of "F1" can be set as 1.

카테고리

도움말 센터File Exchange에서 Simulink Coder에 대해 자세히 알아보기

제품

릴리스

R2018a

질문:

2018년 12월 2일

댓글:

2018년 12월 19일

Community Treasure Hunt

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

Start Hunting!

Translated by