MATLAB Answers

How to pass a changing value from workspaces to Simulink?

3 views (last 30 days)
Hi everyone,
I'm trying to pass a value from workspaces to Simulink calculated by Matlab step-by-step. This value changes each step, but the Simulink simulation take the first value and keep it costant. I'm using simin block and doesn't refresh data. How can I solve this issue?

  1 Comment

Ameer Hamza
Ameer Hamza on 28 May 2020
How is value changing in base workspace? Are you running a loop which changes the value of the variable?

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 28 May 2020
Edited: Ameer Hamza on 28 May 2020
If the value is continually changing in the base workspace, you need to use MATLAB function block and evalin() to read the updated value at each time-step. See the attached file (saved in R2020a). It reads the value of variable 'x' from base-workspace.


Andrea Strappato
Andrea Strappato on 28 May 2020
Thank you for the clear answer and the Simulink model provided as an example. Now it works!!!
Thank you so much!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!