When exporting Simulink Simulation data to .mat files, the data is stored as a Simulink.SimulationData.Dataset class which houses all the recorded signals (of class Simulink.SimulationData.Signal). Is it possible to extract all of the signal value data into new array variables with the same signal names?
For examples, DS (1x1 dataset) contains the two signals: speed (1x1 signal) command (1x1 signal)
Then I’d like to programmatically create the following variables in my workspace from DS where each variable contains only their data values: Speed (100x1 double) Command (100x1 double)
My initial thought was to write a script to create new variables in a for loop. Something like the following:
NumDatasetElements=data.numElements
for a = 1:NumDatasetElements
data{a}.Name=data{a}.Values.data
end
This obviously doesn't work, but I think it shows what I'm trying to do. I need to create a variable with the name data{a}.Name and then set it to data{a}.Values.data.
The reason I'm trying to do this is because I've found that a .mat file populated with array variables easily imports into Python as a dictionary using the sio.loadmat function, whereas datasets do not. My end goal is to easily import Simulink Simulation data into Python to utilize matplotlib for data plotting.