define variable value in simulink model

조회 수: 955 (최근 30일)
yoni stein
yoni stein 2017년 8월 6일
답변: Reid Spence 2024년 1월 22일
Hi,
I use variable 'L' inside gain block.
How can I define the value for 'L' without using the command window in Matlab? I want the user can edit the variable value In the model, something like in the added image. <<
>>
Thank you!

채택된 답변

Rajani Metri
Rajani Metri 2020년 2월 11일
Use "Model Explorer" from View Option . Then Select Simulink Parameter and Add. Then Rename the 'Parameter' with the variable you set in the Simulation and write the 'value', close the window.
Then RUN the simulation, it will take the values of the Gain Block directly, no need to write the values in the Command Window.

추가 답변 (2개)

ES
ES 2017년 8월 7일
Instead of a Gain, use a divide(product) block. First argument is the signal, Second will be from a data store read (the pair of data store write).
  댓글 수: 1
yoni stein
yoni stein 2017년 8월 9일
thanks. That will work, but it ain't pretty..

댓글을 달려면 로그인하십시오.


Reid Spence
Reid Spence 2024년 1월 22일
It depends on what is meant by "the user can edit the variable value In the model". If you want the user to be able to directly modify L on the block, then you can create a mask for the block and make "L" a mask parameter. Now "L" is modifyable directly on the block dialog.
In the picture you show a Constant block feeding into a Datastore Memory block. In most cases, we would not recommend setting the value of a parameter (like L), with the value of a signal (like the output of a constant block). See the page below for the difference between parameters and signals, and how to use the parameter writer block if you really need to do this.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by