exchange data between blocks using Workspace in Simulink.

1 view (last 30 days)
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,

Accepted Answer

Birdman
Birdman on 14 Apr 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 Comments
Birdman
Birdman on 15 Apr 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.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!