DataSet vs ModelDataLogs data retrieval
조회 수: 3 (최근 30일)
I'm converting tests from MATLAB 2011A to 2018B. THe post-processing uses the statements:
With sim output in ModelDataLogs:
logsout = evalin('base','logsout'); % Get logsout from workspace
log.unpack('all'); % unpack signal logs
time = ([1 4.5 5 6 9.75-(1/60) 15.2 20 24 29.9 30 37 58 62 66 72 74.8 80 81 85 90 145 145.2 150 153.6]*60)+1;
time = double(time);
if var1.Data(time(1)) == 0
What is the conversion to the DataSet format to do the same processing?
gives the result:
BlockPath: [1×1 Simulink.SimulationData.BlockPath]
Values: [1×1 timeseries]
How do I get the value for a given variable name and time?
The output structure is 2 columns : time and data
I was able to get the format for retrieving a value when I know the index.
[dsout, idx] = find(logsout,'Name', 'var1')
gives me a 22
gives me the value.
The next problem is finding the index for a certain time value
i.e What is the index when time = 1.1067
I need to find
logsout.getElement('var1').Values.Data(index of time =1.1067)
Sara Nadeau 2019년 4월 3일
The Dataset object contains Signal objects, and the data in the Signal object - what you describe as 'the output structure' - is actually a timeseries object.
Each object - Dataset, Signal, and timeseries - has a set of functions/methods you can use to operate on that object.
I am not sure that the line you use to get the index of 22 is doing what you intend.
Take a look at the getsampleusingtime function for the timeseries object. I think this might work for you. You pass in a timeseries object (which you access using logsout.getElement(elidx).Values) and time values, and the return is a timeseries object where the data includes only the values for the specified time, which you can then check against your test criteria.
I hope this helps!