- matlab.lang.makeValidName - https://www.mathworks.com/help/matlab/ref/matlab.lang.makevalidname.html
- assignin - https://www.mathworks.com/help/matlab/ref/assignin.html
Is it possible to convert Simulink.SimulationData.Dataset signals into individual array variables?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
0 Kommentare
Antworten (1)
ag
am 7 Nov. 2024 um 11:01
Hi Mark,
To extract values from a "Simulink.SimulationData.Signal" into array variables, you can iterate over the signals in the dataset and dynamically create variables using the "matlab.lang.makeValidName" function. You can then assign the respective values using the "assignin" function.
The following code snippet demonstrates this process:
% Loop through each element in the dataset
for i = 1:numElements(DataSet)
signal = DataSet.get(i);
signalName = signal.Name;
signalDataArray = signal.Values.Data;
% Create a valid variable name and assign the data to the base workspace
varName = matlab.lang.makeValidName(signalName);
assignin('base', varName, signalDataArray);
end
For more details, please refer to the following MathWorks documentations:
Hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Save Run-Time Data from Simulation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!