MATLAB Answers

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

4 views (last 30 days)
Brandon1363
Brandon1363 on 28 Jul 2016
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?
Thanks!
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: ''

Answers (2)

Shameer Parmar
Shameer Parmar on 29 Jul 2016
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']);
end
To check the list of DatatType.. Type this..
ListOfDataType
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 Comments
Shameer Parmar
Shameer Parmar on 1 Aug 2016
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 properties..like 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..

Sign in to comment.


Satishkumar Aruljothi
Satishkumar Aruljothi on 2 Aug 2016
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 =
fixdt(0,8,10,0)

Community Treasure Hunt

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

Start Hunting!