필터 지우기
필터 지우기

Is tit possible to connect a push button to source?

조회 수: 1 (최근 30일)
Simon Ravelingien
Simon Ravelingien 2015년 12월 12일
답변: goerk 2015년 12월 14일
I'm creating a model in Matlab Simulink that uses a Bernoulli binary source that generates a random vector. For now, this source generates a vector every time period, so the sample time is set to 1. But how can I link the sample time to an extern parameter, so this source can e.g. be triggered to generate a vector at non predefined moments? Actually I want to generate a vector every time I click the push button.

답변 (1개)

goerk
goerk 2015년 12월 14일
You can use a Constant-Block (name it myRandInput) and change the value of this block over the OpenFcn (open function callback) of an empty Subsystem. (Right-Click on the Subsystem -> Properties -> Callbacks)
Or you can use an annotation ClickFcn. (Double-Click into the model -> Name the annotation: e.g. ClickHere -> Click outside the annotation -> Right Click on the annotation -> Properties -> ClickFcn)
In this functions you can create a random number and write it to the Constant value.
myValue=rand;
modelName = gcs;
set_param([modelName '/myRandInput'],'Value', num2str(myValue));
Note: The Constant-Block is named: myRandInput

카테고리

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