This function does not fully set the dimensions of output port 2 error in matlab?

368 ビュー (過去 30 日間)
hi. I simulated impedance control for ur10.but there is an error:
Error in default port dimensions function of S-function 'impedance2/impedance controller'. This function does not fully set the dimensions of output port 2
I guess it the problem is with x signal. x is 1 if this is wrong. the signal should be 6,1 in ur10forwardkinematic block. I don't know where is output port2 exactly and how can I fix this problem? The Simulink file is attached.


Sebastian Castro
Sebastian Castro 2018 年 11 月 6 日
Hi Najmeh Eskandari,
I would highly recommend running this code in MATLAB and debugging it yourself. I just did the same and your line 153 seems to have incorrect MATLAB code that causes an error.
C(k,j)= C(k,j)+0.5*(diff(D(k,j),q(i,1))+diff(D(i,k),q(j,1))-diff(D(i,j),q(k,1)))*dq(i,1);
Error using diff
Difference order N must be a positive integer scalar.
Try starting by fixing that. The second input to the diff function is actually just the number of differences to compute (so it should be an integer), but you are passing in values like q(j,1) and q(j,2) which are noninteger joint angle values, so this is incorrect.
- Sebastian
  4 件のコメント
Najmeh Eskandari
Najmeh Eskandari 2018 年 11 月 6 日
Thank you Sebastian.I'll try your suggestion.


その他の回答 (1 件)

Nicolas Schmit
Nicolas Schmit 2018 年 10 月 15 日
Simulink is having a hard time determining the dimension of the outputs of the MATLAB Function blocks. The root cause is that you have many undefined variables in the code of the MATLAB function blocks. Because of those undefined variables, MATLAB cannot execute the code of the blocks and thus cannot determine the dimension of the outputs.
  1 件のコメント
Prasath Lingan
Prasath Lingan 2021 年 11 月 19 日
Yes, You are absolutely right. After deleting all the variables that are used but not defined, the issue is gone. Thanks.



Find more on Block Authoring and Simulation Integration 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!

Translated by