MATLAB: How to save parameters of masked subsystem to workspace

save parameters of masked subsystem to workspacesim

Hello, I am a simulink leaner. I have one problem needs your suggestion and help. Thank you. In my simulink model A, there are several masked subsytems (a,b,c.. ), in which the parameters are defined ({x1} for a; {x2} for b;…).
The output port "Out1" of model A denotes my object result, but it should be a iterative result. I have to set a loop run for model A based on intial [{x1}, {x2}, {x3}… ]. The "Out1" should be returned to main arithmetical program, and the main program will assign updated {x1'} for masked system a; {x2'} for masked system b;…
I am using the "sim" in the circumstant, and met all these problems. Thank you. I am not sure which commands are supposed to use. Or there is more suitable command? Thank you.

Best Answer

By default, signal on output port "Out1" is logged into workspace as "yout". After every iteration of your sim() run, you can check the value of yout in the workspace. The signal for "Out1" should be the first column of yout. Based on the value, you can use set_param() to change the parameter for your masked subsystem and then repeat the simulation.