Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

how to pass variables from simulink to workspace,when simulink has been paused from MATLAB Script

Asked by Arun Badigannavar on 14 Dec 2012

I am running two simulink model from matlab script(with "sim" command),,now i want to pause the running simulink model in the middle and send the data from "to workspace block" to my matlab workspace at the time wen i paused it,,,,,actually my requirmnet is meeting if i directly run my simulink model from simulnk start pause button,,,but its not working through script

4 Comments

Arun Badigannavar on 14 Dec 2012

help me out,,if anyone know abt this

tulika Roy on 31 Dec 2012

I am running the simulink model with a script file I am taking a for loop, after 1 cycle value model runs but in next cycle value it deleted the old value. figure I can use using 'hold on' but how to store and retain old array?

Arun Badigannavar on 3 Jan 2013

Start a new question thread Tulika Roy

Arun Badigannavar

Tags

Products

No products are associated with this question.

2 Answers

Answer by Azzi Abdelmalek on 14 Dec 2012

Use

 set_param('Yourmodel','Simulationcommand','start')

and your data will be saved to workspace

5 Comments

Azzi Abdelmalek on 17 Dec 2012

What is 'lenthier' ?

Arun Badigannavar on 17 Dec 2012

I mean to say i have to write for loop again

Azzi Abdelmalek on 17 Dec 2012

Arun, I tested your problem in a loop, and it worked, the initial value of the unit delay don't change when you pause simulation. I don't know why it don't work for you.

Azzi Abdelmalek
Answer by TAB on 14 Dec 2012

@Arun, I hope that you don't have any strange varsion of matlab (like Matlab R. Strange).

sim() command will not return till simulation is completed, so off-course your script will never go ahead to execute other commands like pause.

And, see below snap. When I run and pause the model from script using SimulationCommand, then To Workspace block output is saved in workspace. It should work for you also.

18 Comments

Azzi Abdelmalek on 18 Dec 2012

I do'nt understand. Even you pause your simulation, your data will be in workspace.

Arun Badigannavar on 19 Dec 2012

I am controlling my simulink models in a for loop from matlab script,,so wen i pause the from script,,,its reall not giving values back to workspace,,,,,

Arun Badigannavar on 19 Dec 2012

HELLO Mr TAB,,,in your screenshot You have added a breakpoint so u r getting the values to workspace,,,

TAB

Contact us