'Error in default port dimensions function of S-function', 'This function does not fully set the dimensions of output port 2'
이전 댓글 표시
Hi there, I have created a manoeuvring prediction code and am trying to just read an excel document within the matlab function. The errors 'Error in default port dimensions function of S-function', 'This function does not fully set the dimensions of output port 2' come up when I try to do this. It works perfectly fine when I just input the coefficients and parameters in manually, but I want the user to just be able to use an excel sheet to put in their variables for this code.
Does anyone know how I can get this to work?
Sorry for the lack of knowledge, I'm not exactly a Matlab wizard.
Thanks in advance.
댓글 수: 8
Walter Roberson
2019년 8월 4일
Please show all of fcn
Michael Dunn
2019년 8월 4일
Walter Roberson
2019년 8월 5일
It would be easier if you attached the .m instead of having to work with pictures of the code.
Michael Dunn
2019년 8월 5일
Divya Gaddipati
2019년 8월 7일
Hi,
Could you provide the excel file as well? The could be a mistake in the excel format.
Michael Dunn
2019년 8월 8일
Divya Gaddipati
2019년 8월 9일
Could you attach the script for reading the excel file as well?
Michael Dunn
2019년 8월 11일
답변 (2개)
Divya Gaddipati
2019년 8월 12일
0 개 추천
In line 50 of your ManoeuvringCode.m, the variable X_u is defined as an expression which is present in your excel sheet in row 45 as well. When you are reading your excel file using xlsread, it is extracting that expression as NaN. Hence, your output port 2, which is v_dot is not defined properly as it depends on X_u, which could be NaN in some cases (u >= 0.1). Try defining X_u in the code itself and not from the excel.
댓글 수: 8
Michael Dunn
2019년 8월 12일
편집: Michael Dunn
2019년 8월 14일
Walter Roberson
2019년 8월 14일
What output is required if the excel entry is read as nan?
Michael Dunn
2019년 8월 14일
Walter Roberson
2019년 8월 14일
X_u is defined by a formula in row 45,not by a numeric constant. When you read the spreadsheet then the reader automatically replaces formula with nan. You need to change how you read X_u so that you can get out a formula that you can apply.
Walter Roberson
2019년 8월 15일
It looks like you are not reading as far as row 45, so that would not appear to be the problem.
I was concerned that the GOTO for several variables might not have been initialized, but I see that you are using memory blocks set to 0 to define initial conditions to the integrators whose output is GOTO over to the inputs, so that should be okay.
Michael Dunn
2019년 8월 15일
Walter Roberson
2019년 8월 15일
It just might help to use block parameters or an initial conditions block to initialize all the values that you GOTO into the function.
Michael Dunn
2019년 8월 15일
카테고리
도움말 센터 및 File Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!