How to use set_param correctly in a function

When I execute the following program in a function, each process can be performed, but the data in the To workspace is not reflected in the base workspace.
What is the difference between this and script execution?
Also, is there a way to solve this problem?
set_param('vdp','SimulationCommand','pause')
set_param('vdp','SimulationCommand','continue')

 Respuesta aceptada

Walter Roberson
Walter Roberson el 1 de Sept. de 2021

0 votos

The To Workspace block typically writes data to the MATLAB® base workspace. For a sim command in a MATLAB function, the To Workspace block sends data to the workspace of the calling function, not to the MATLAB base workspace. To send the logged data to the base workspace, use an assignin command in the function.

4 comentarios

A
A el 1 de Sept. de 2021
Can I also run Simulink to send data from the function workspace to the base workspace in real time?
Walter Roberson
Walter Roberson el 6 de Sept. de 2021
No. Simulink does not send data to the base workspace until it ends or the simulation is paused .
A
A el 6 de Sept. de 2021
Is there a way to pause/stop Simulink that I can run within a function?

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Versión

R2021a

Preguntada:

A
A
el 1 de Sept. de 2021

Comentada:

el 6 de Sept. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by