필터 지우기
필터 지우기

Change Simulink.Signal initial value programmatically

조회 수: 3 (최근 30일)
Aviad Aviad
Aviad Aviad 2018년 6월 9일
답변: Brahmadev 2024년 2월 8일
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.

답변 (1개)

Brahmadev
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:
  1. 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.
  2. Enter y in the Signal Name edit field.
  3. Enable "Signal name must resolve to Simulink signal object"
Now you can programatically set the value of Simulink.Signal object. Hope this helps!

카테고리

Help CenterFile Exchange에서 Modeling에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by