Programmatically get propagated datatype of a block
9 次查看(过去 30 天)
显示 更早的评论
I am trying to get a block propogated datatype when the output datatype is selected to inherit. I know we can use get_param to get datatype setting but I am interested in getting datatype a block outputs post update model (Ctrl+D).
I have a model with fixed point datatypes where some of the blocks are inheriting the datatype. I want to pin-point which block is using a perticular word length post propogation.
0 个评论
采纳的回答
Andy Bartlett
2022-7-5
Hi,
The attached function provides an example of how to use Simulink API's to get data type information from signals and run-time parameters.
This can be run like so.
mdl = 'fxpdemo_feedback';
open_system(mdl);
[cellDts,cellDtStrs,rootOutCellDts,rootOutCellDtStrs,S] = find_all_dt_io(mdl)
You can see the list of data types detected as numerictype objects or as strings. Here is an example of seeing the string names used by Simulink.
S.cellDtStrs
ans =
1×5 cell array
{'double'} {'sfix16_En14'} {'sfix16_En5'} {'sfix32_En12'} {'sfix8_En4'}
To see where a particular data type was detected, you can use the data type name as a field name for the last function output argument.
S.sfix16_En14
ans =
struct with fields:
ntStrML: 'numerictype(1,16,14)'
ntStrSL: 'fixdt(1,16,14)'
nt: [1×1 embedded.numerictype]
RtParam: {1×2 cell}
Inport: {'fxpdemo_feedback/Controller/Numerator Terms'}
Outport: {'fxpdemo_feedback/Controller/Up Cast'}
That data type was used as an input to one block and the output from another block.
The data type was also used with Run-Time parameters of two blocks.
S.sfix16_En14.RtParam
ans =
1×2 cell array
{'fxpdemo_feedback/Controller/Denominator…'} {'fxpdemo_feedback/Controller/Numerator T…'}
You can look inside
edit find_all_dt_io
to see what it's doing. It's using the techniques that Fangjun Jiang mentioned. Plus, getting the Run-Time Parameter information.
Regards,
Andy
更多回答(1 个)
Fangjun Jiang
2022-7-4
Something like
model([], [], [], 'compile')
get_param('BlockPath','CompiledDataType')
model([], [], [], 'term')
You can use this to get all the compiled data types and then search for a paticular data type string.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!