exchange data between blocks using Workspace in Simulink.
1 visualización (últimos 30 días)
Berkin Birol el 13 de Abr. de 2018
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,
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: