필터 지우기
필터 지우기

exchange data between blocks using Workspace in Simulink.

조회 수: 1 (최근 30일)
Berkin Birol
Berkin Birol 2018년 4월 13일
댓글: Berkin Birol 2018년 4월 15일
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,

채택된 답변

Birdman
Birdman 2018년 4월 14일
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
Birdman
Birdman 2018년 4월 15일
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 2018년 4월 15일
It worked, thanks again :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by