- Open th Simulink mode. Right click on the Signal that you want to connect to "y". Go to properties. This will open the "Signal Properties" dialog box.
- Enter y in the Signal Name edit field.
- Enable "Signal name must resolve to Simulink signal object"
Change Simulink.Signal initial value programmatically
6 次查看(过去 30 天)
显示 更早的评论
Hi,
I used the following guide to create a Simulink.Signal object in my Simulink model via Model Explorer: https://www.mathworks.com/help/simulink/ug/using-global-data-with-the-matlab-function-block.html
I gave the Simulink.Signal object an initial value via the model explorer and used it in a MATLAB function block in my model, but its value is constant and I would like to be able to change it in my main program.
My question is: how can I set the value of this Simulink.Signal programmatically using MATLAB code?
Thanks in advance.
0 个评论
回答(1 个)
Brahmadev
2024-2-8
For programatically editing a Simulink.Signal object from the command window, we should first define it in the base workspace. See example below:
>> y = Simulink.Signal
>> y.CoderInfo.StorageClass = "ExportedGlobal";
>> y.CoderInfo.Identifier = "y"
>> y.InitialValue = ""
Now, "y" can be used in simulink by using the following steps:
Now you can programatically set the value of Simulink.Signal object. Hope this helps!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!