Info

This question is closed. Reopen it to edit or answer.

How can I acces Data from Simulink when the model gets called in a function?

1 view (last 30 days)
Hello,
I have written a GUI and the callback of a button is a function that saves input and starts a simulink model.
I would like to get back the resulting data to the GUI to plot them, right now I have to use a scope block and switch between windows.
But the "To Workspace" Block and the logging function of the scope both only work when I press play directly in Simulink.
It does not work when I use the "sim" command in the nested function, even if I initialize the variables before the function.
Just nothing happens.
Can anybody give me a hint how to work around this problem?
Thank you!
  1 Comment
David K.
David K. on 18 Sep 2019
How is it that you are doing it? To test it I made a simulink function with a "To Workspace" block and accessed it in a function as such:
function letsTest()
simout = sim('myModel');
figure;
plot(myData.Time,myData.Data)
This seemed to work fine which would also imply to me that I could use that data and return that data as desired. My save format for the simulink block is time series in case that might matter.

Answers (0)

Products


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!