take the real data type of parameters from the Simulink model
7 views (last 30 days)
Hi! What do you think about this?
I'm using R2009b Matlab version. I have my_para.mat set of parameters that are used in my_model.mld.
My problem is related to the data type of these parameters. Even if my 'para1' parameter is used as uint16 in the Simulink model, Matlab takes it as double. What can I do to take the real data type directly from the model? I have a GUI interface and I need only to display these real data types.
Thank you in advance!
Fangjun Jiang on 15 Sep 2011
When you create your .mat file, use the following to set up the value and then save to the .mat file.
When you try to get the data type of this parameter, use
James on 15 Sep 2011
In the Simulink model use a Data Type Conversion block. It's in Commonly Used Blocks.
When I've wrestled with this I found it easiest (i.e. most predictable/reliable) to take in everything as doubles and to output it as doubles in and out of the Simulink model.
Your question is still not clear. What is 'corresponding block '
If you mean 'constant' blocks and you want output datatype of these blocks then try this.
CBlks= find_system(h, 'SearchDepth',2,'FindAll', 'on', 'BlockType', 'Constant');
'CBlks_Name' will store names of constant blocks and 'CBlks_DType' will store thier output datatypes. You can send them anywhere you want.
You may using parameter name in the 'Constant value' field of constant block.
using get_param() you can retrieve the properties of model and any blocks. Similarly you can set thier properties using set_param().
For list of model and block properties please see
TAB on 22 Sep 2011
Answer is in you question itself (See comment). gcs specifies the currently selected system or subsystem.
Take handle of model and use it with find_system(). Also go through the option available for find_system().
blks = find_system(mdlhandle, 'Type','block');
blks = find_system(mdlhandle, 'FindAll','on','Type','block');
listblks = get_param(blks, 'BlockType');
listblksname = get_param(blks, 'Name');