Question
I'm using "setVariable" to update a variable in a test harness. I'm using the command evalin('base', 'y_coordinate') in a "From Workspace" block to load the variable into Simulink. However, in R2019b the variable doesn't seem to get updated. Why does this happen?
Expert Answer
Kshitij Singh
PhD Expert
Answered Aug 13, 2026
In R2019b, the behavior of "setVariable" is modified such that it overrides only model variables (as opposed to MATLAB variables).
I attached a simpler model ("SimpleVars_R2019b.slx") to help illustrate this. This model has two "From Workspace" blocks, one set to "a" and one set to "evalin('base', 'b')".
If you call "findVars" on this model, only "a" is considered to be a model variable, even though both output their timeseries when run:
>> vars = Simulink.findVars('SimpleVars_R2019b')
vars =
VariableUsage with properties:
Name: 'a'
Source: 'base workspace'
SourceType: 'base workspace'
Users: {'SimpleVars_R2019b/From↵Workspace'}
The R2019b behavior provides stricter control of overrides and achieves parity with other Simulink tools. You will need to update the model to use variables which are recognized by Simulink.
Please update the "From Workspace" block variable parameter from "evalin('base', 'y_coordinate')" to just "y_coordinate". Then save the model and run the test file again.
You should observe that "setVariable" updates all of the variables now.
100% Run Guarantee
3-Hour Fast-Track Delivery
Need a Custom Version or Complete Simulation for This Problem?
Our 500+ PhD engineers build, debug, and optimize working MATLAB scripts and Simulink (.slx) models tailored to your exact assignment rubrics with zero plagiarism.
Tested on MATLAB R2024b / R2026a
Turnitin 0% Plagiarism Report
Free 7-Day Revisions Guarantee
Have a different question? Ask here
Related simulink Questions & Solutions
Browse All →
Explore similar technical troubleshooting questions and verified MATLAB solutions:
Ready-to-Run MATLAB & Simulink Projects
Browse All Projects →