Generating code for a subsystem accepting structure parameter
1 view (last 30 days)
Show older comments
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 Comments
Babak
on 1 Aug 2012
- 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.
Answers (1)
TAB
on 12 Jul 2012
Edited: TAB
on 12 Jul 2012
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 Comments
See Also
Categories
Find more on Simulink Coder in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!