MATLAB Answers

Is there a way to get a signals properties in Matlab?

12 ビュー (過去 30 日間)
Brandon1363 2016 年 7 月 28 日
回答済み: Satishkumar Aruljothi 2016 年 8 月 2 日
Hello, I need to pull a signals data type as its shown in the properties below. Is there a way for me get this information using get_param or another function?
Signal with properties:
CoderInfo: [1x1 Simulink.CoderInfo]
Description: 'PCC Set speed offset converted to fixed point'
DataType: 'fixdt(1,16,0.100000,-0.000000)'
Min: -125
Max: 125.9960
DocUnits: 'KmPh'
Dimensions: -1
DimensionsMode: 'auto'
Complexity: 'real'
SampleTime: -1
SamplingMode: 'auto'
InitialValue: ''

  0 件のコメント


回答 (2 件)

Shameer Parmar
Shameer Parmar 2016 年 7 月 29 日
It looks like you want to access the datatype of signals added into your BaseWorkSpace.
Lets consider if signal "a", "b", "c" are added into BaseWorkSpace then, Simply you can do this..
listOfSignals = who;
ListOfDataType = {'Signal Names', 'DataType'};
for i=2:length(listOfSignals)+1
ListOfDataType{i,1} = listOfSignals{i-1};
ListOfDataType{i,2} = eval([listOfSignals{i-1},'.DataType']);
To check the list of DatatType.. Type this..
OutPut will be..
ListOfDataType =
'Signal Names' 'DataType'
'a' 'auto'
'b' 'boolean'
'c' 'fixdt(1,16,0.100000,-0.000000)'
Please Note:
1. While running this code.. make sure, only Simulink Signals\Parameters are present in your Base Workspace.. if your BaseWorkSpace contains any other type of dataobjects, (which dont have the property called 'DataType') then it may cause an error.. So to resolve such error, you may have to apply such if condition under this For Loop...
2. If you have dont have Signals present in BaseWorkSpace OR different Requirement, then this code will not work.. So let me know your requirement in details, like, from where you accessing these Signals ?

  2 件のコメント

Brandon1363 2016 年 7 月 29 日
Unfortunately my Base Workspace has different types of data objects that do not have the property called 'DataType'. So I am getting an error. I am pulling these signals from a Simulink model in order to set annotations for specific blocks, based on their data type information. I'm only dealing with one signal at a time.
Shameer Parmar
Shameer Parmar 2016 年 8 月 1 日
Ok.. So how you pulling the signals from your model.. Because the Data (properties) you pasted in your question only get if you added signal in your Base WorkSpace.. The signal data (properties) you pasted in your question shows that, it is present in Base WorkSpace as Simulink.Signals... Only when it shows these Description, Min, Max, CoderInfo, Complexity etc etc..
So please confirm on how you got these signal properties from your model then may be I can help you..


Satishkumar Aruljothi
Satishkumar Aruljothi 2016 年 8 月 2 日
I think you are trying to retrieve 'data type' from CSC type variable.
you can simply use variable_name.DataType.
>> Myvariable1
Myvariable1 = Properties: Value: 2000 CoderInfo: [1x1 Simulink.CoderInfo] Description: 'maximum allowed ' DataType: 'fixdt(0,8,10,0)' Min: [] Max: [] DocUnits: '' Complexity: 'real' Dimensions: [1 1]
>> Myvariable1.DataType
ans =

  0 件のコメント


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by