'Error in default port dimensions function of S-function', 'This function does not fully set the dimensions of output port 2'

22 ビュー (過去 30 日間)
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 件のコメント
Divya Gaddipati
Divya Gaddipati 2019 年 8 月 9 日
Could you attach the script for reading the excel file as well?
Michael Dunn
Michael Dunn 2019 年 8 月 11 日
I have attached it. Just to clarify, this script is not the issue at all. I can import any values from the excel sheet fine using this script, so there is not issue with that. I simply desire to import the excel values within the function as previously described.
Thanks.

サインインしてコメントする。

回答 (2 件)

Divya Gaddipati
Divya Gaddipati 2019 年 8 月 12 日
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 件のコメント
Walter Roberson
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
Michael Dunn 2019 年 8 月 15 日
I apologise for my lack of knowledge, but I am unsure how I would do this. Would I complete this in the Simulink model or within the MATLAB function?

サインインしてコメントする。


Michael Dunn
Michael Dunn 2019 年 8 月 14 日
I think I have not communicated something correctly. In the excel sheet I have provided, the coefficients 'Y_dr', K_dr', N_dr', etc. are shown. The user is required to provide the coefficients only, not as a formula. The MATLAB code will use this numeric constants to define the formula by multiplying them by their respective velocities. I have attached an updated script that shows what I mean with this. This script works perfectly by itself, but I cannot put it into the 'AUV_mathemanical_model_ver7.slx', it simply does not work within this and runs the error as shown previously.

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by