Hi, would someone be willing to assist me in resolving this error
2 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1497769/image.png)
采纳的回答
Akshat
2023-10-1
编辑:Akshat
2023-10-1
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 个评论
Akshat
2023-10-2
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
2023-10-3
编辑:Fangjun Jiang
2023-10-3
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!