I'm reusing old code that in some phase generates a variable that I'd like to use in my own code. The problem is that this variable (basically a SimState from a just run Simulink simulation) is not reachable from my code because is stored in another stack. I've tried to move the variable with assignin and evalin but I've failed.
Is there any way to move from a ws to another (not necessarily 'base' and first 'caller') not in debug? I think this is not possible but maybe you can suggest some work around.
The structure of the code is the following:
% Setting the simulation to provide a snapshot of the state of the simulator at the end of the simulation set_param(model_1,'SaveFinalState','on','FinalStateName',... 'xFinal','SaveCompleteFinalSimState','on','LoadInitialState', 'off') % Simulation function Simulation_fun(Parameter_set_1) ..existing code containing many functions and finally a sim(model_1)
Having set the simulation as above the xFinal is stored in the workspace at the end of the simulation but this is not anymore reachable by my code (because in a different stack). Here I would save the final state 'xFinal' to re-initialize another following simulation with the same simulator (model_1) with some changes on the initialization parameters (mass, position...). Something like: evalin('base', sprintf('save(''%s'',''%s'')','xFinalFile','xFinal'));