Hi, would someone be willing to assist me in resolving this error
2 views (last 30 days)
Show older comments
Accepted Answer
Akshat
on 1 Oct 2023
Edited: Akshat
on 1 Oct 2023
I understand that you require assistance in resolving an error. I investigated the screenshots attached and observed that the error reflects an attempt to modify the value of a Simulink Input. I am assuming that you wish to overwrite the value of the variable 'selectedOutput' during simulation. To achieve this, you can leverage the 'assignin' function to assign the value in a specific workspace and allow the simulation to take the updated value from next time step.
In reference to the code attached, the variable 'selectedOutput' can be assigned through 'assignin' function as
% assuming that the variable is defined in the base workspace
assignin('base', 'selectedOutput', tegVoltageRange);
Read more about 'assignin' function: https://in.mathworks.com/help/matlab/ref/assignin.html?s_tid=doc_ta
I hope this helps.
3 Comments
Akshat
on 2 Oct 2023
Great that it worked for you! If you could kindly mark it as accepted, it would be greatly appreciated. This way, if someone else encounters a similar issue, they can also benefit from this workaround.
Fangjun Jiang
on 3 Oct 2023
Edited: Fangjun Jiang
on 3 Oct 2023
The error messages come from Stateflow. The OP must have defined those two variables as "input" data to the Stateflow but still try to assign values to those variables in the function (which must have been inside the Stateflow too), thus the error. A similar question has been asked by the OP and has been answered before.
'selectOutput' referenced by the error message points to the name of the function. 'selectedOutput' is a variable inside the function but does not involve any error. This mis-led to this answer that is irrevant to the error.
You seemed to struggle on the same issue for a long time but without making progress.
I suggest you clearly explain your original task or what you want without involving any Simulink model, because your model snip does not make sense and it is mis-leading.
More Answers (0)
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!