- 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
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Brahmadev
am 8 Feb. 2024
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 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!