Generating code for a subsystem accepting structure parameter
14 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm trying to generate code (using S-function target TLC) for a subsystem with several components accepting parameters, which are fields of a Matlab variable of type structure. I would like the structure parameter fields be tunable in the generated code. - Non-tunable rate transition, ZOH, etc. blocks' parameters are not fields of this structure. - Tunable parameter syntax restrictions in Constant source blocks (such as avoiding [,] and structure referencing) are followed. - A Simulink.Parameter object with value struct is defined in the Base Workspace. - When building the subsystem, this parameter is checked to be "tunable".
However, During the build process Matlab returns a warning in the command window telling me that the the parameter X, which is my structure parameter, is not a built-in type therefore cannot be tunable. Apart from this issue the build process turns out to be OK.
Any ideas what may have gone wrong?
Thanks in advance, Sinan Pakkan
4 个评论
Babak
2012-8-1
- Not all block's parameters are tunable.. for example sampling time cannot be tunable - you also need to create a Simulink.Bus object and set the DataType of the Simulink.Parameter object as the Bus object you just created... this way in the generated code, the structure's fields appear correctly. -MATLAB spits warning for some of the Tunable parameters still if they are places inside a vector like [a,b] or are in the form of a power like a.^3.
回答(1 个)
TAB
2012-7-12
编辑:TAB
2012-7-12
I think problem is due to you are using multi-level (a few fields of the structure are themselves structures) structure.
Try using a structure which contains numerical values in all the fields.
MyStruct.Value1 = 100;
MyStruct.Value2 = 200;
MyStruct.Value3 = 500;
MyParam = Simulink.Parameter;
MyParam.Value = MyStruct;
I can't test this feature because I am far behind in the race and using R2007a. *:-(*
2 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!