How do i save the outputs of a simulink simulation runs by sim command to base workspace?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Berkin Birol
am 25 Dez. 2019
Kommentiert: Berkin Birol
am 26 Dez. 2019
I'm running a simulation with the "sim" command like:
sim('mySim', 'SimulationMode','accel','StopTime', '1000')
The simulation completed but the outputs are not written to base workspace. If i run the simulation manually in simulink, all outputs are there, in base workspace. But if I run the simulation through the sim command, I can not access them. If i use a command like below, I get these outputs in a single varible as 1x1 SimulationOutput. but I need them seperately. So this method does not work for me.
mySimOut=sim('mySim', 'SimulationMode','accel','StopTime', '1000')
I need the outputs seperately because I will export them one by one to excel afterwards. I have multiple timeseries outputs in this simulatın, is there a way, preferably an easy way, to export all data produced in this simulation (simulated by sim command) to the base workspace?
Please help :)
Thanks in advance.
0 Kommentare
Akzeptierte Antwort
megha pawar
am 26 Dez. 2019
Post simulation you can run below script , it will extract variables from simulation output structure to base workspace
Parm_List=get(mySimOut);
for Param_No=1:1:length(Parm_List);
mySimOut(1,1).find(char(Parm_List(Param_No,1)));
assignin('base',char(Parm_List(Param_No,1)),mySimOut(1,1).find(char(Parm_List(Param_No,1))))
end
Weitere Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!