exchange data between blocks using Workspace in Simulink.

2 visualizaciones (últimos 30 días)
Berkin Birol
Berkin Birol el 13 de Abr. de 2018
Comentada: Berkin Birol el 15 de Abr. de 2018
Hi all,
I am not experienced with MATLAB and Simulink, so I'm having some trouble to communicate two blocks with each other. I want to produce and update a variable set in a Simulink simulation and use them in the same simulation in different places and I want to achieve that using workspace.
I calculate some variables during simulation (using Interpreted MATLAB Function) and I export them to the workspace with 'To Workspace' block. But I can't get the variables as I want with 'From Workspace' block (Actually I couldn't even manage to run the simulation when using FromWorkspace block, due to 'Invalid variable specification' error etc.) I tried timeseries, Array, Struct. I am missing something but I can not find it.
For example, I use 'Interpreted MATLAB Function' and calculate 2 variables during simulation continuously. And in the same simulation I want to use the first variable as an input for the block A and the second variable as an input for the block B. This is a simplified example, I would have 30-40 variables in my simulation, thats why I don't just connect outputs to the inputs directly. I have to communicate those blocks over variables.
How can I use those two blocks ('To Workspace' and 'From Workspace') to select the data (which can change continuously during the simulation) I want with 'From Workspace' block? Or do you have any suggestions to do it in another way?
Thank you in advance,
Berkin,

Respuesta aceptada

Birdman
Birdman el 14 de Abr. de 2018
Actually, you can not use From Workspace or To Workspace blocks to exchange data during simulation. They are meant to be used after the simulation. To achieve your goal, you need to use From and Goto tags which are really useful. I can not help you further since I don't have your model, but try to use From and Goto Tags and let me know the results. Check them from the following links:
  2 comentarios
Birdman
Birdman el 15 de Abr. de 2018
Berkin's answer moved here:
Thank you Birdman, I'll try those two in my simulation and I'll let you know if it's work or not.
Berkin Birol
Berkin Birol el 15 de Abr. de 2018
It worked, thanks again :)

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by