Define and Use Structure Parameters in Simulink

8 ビュー (過去 30 日間)
James Browne
James Browne 2022 年 1 月 6 日
コメント済み: Jan Los 2024 年 3 月 14 日
Hi,
I wanted to use the method in
to import a struct into a matlab funciton block as I am not really familiar with busses (and the help examples I found weren't really on point as I didn't want to create the struct in simulink, I want to read in a struct created in the workspace into simulink and use it in a function block). This help was referenced in some forum posts I found on this site (I can see this issue comes up but I couldn't get the solutions to work for me, so I must be missing something).
When I follow the guide in the above link, i get the error
----------------------------------------
Parameter struct has a value of an unsupported type Parameter Data 'struct'
Component:MATLAB Function | Category:Coder error
----------------------------------------
Is anyone able to assist with where I have gone wrong?

採用された回答

Paul
Paul 2022 年 1 月 6 日
Do you actually have a variable in the base (or model, I suppose) workspace named 'struct'? That would be odd because struct is a built-in function, and normally one doesn't name variables to override built-in function names.
The function signature in the block should be:
[FX,FY,MZ] = solve_function(GAMMA,FZ,alpha_deg,k,mystruct)
mystruct needs to be defined in the base workspace (or I think it can be in the model workspace), and the Scope of mystruct should be set to Parameter in the Ports and Data Manager.
  3 件のコメント
James Browne
James Browne 2022 年 1 月 6 日
infact, that looks like it was the issue. Even though I wasn't calling the text, its existance in the struct caused the problem.
Jan Los
Jan Los 2024 年 3 月 14 日
After searching for hours with a similar "coder error" bug, i found this is the solution.
I added text somewhere in the structure, and this is apparently not allowed in Simulink.
Very strange and unnecessary limitation in my humble opinion. Cleaning up an existing parameter structure from all text to be able to use it in Simulink is annoying and eliminates the significant advantage of having descriptive entries in the structure.
Moreover, it would be very nice if Simulink throws a more descriptive error than simply "coder error".

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by