Define and Use Structure Parameters in Simulink
12 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
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.
4 个评论
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".
engdancili
2024-9-18,8:52
@Jan Los great! I had the same issue and I quickly solved thanks to your comment. I wish there was the possibility to upvote comments.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!