Define and Use Structure Parameters in Simulink

조회 수: 9 (최근 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 CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by