Removing repeat displays in Matlab

2 ビュー (過去 30 日間)
James
James 2015 年 4 月 2 日
編集済み: A Jenkins 2015 年 4 月 2 日
I am modelling a landing gear system and would like to be notified in the Matlab command space when it has been deployed
To do this I have a matlab function block in simulink with the following code:
--------------------------------------------
function y = fcn(u)
if u >= 0.5
disp('Nose LG Door 2 Deployed')
end
y = u;
-----------------------------------------
However I only want the display of Nose LG Door 2 Deployed to come up once in the command window, except currently it is constantly repeating until the simulation ends.
Does anyone know how to make it only appear once?

回答 (1 件)

A Jenkins
A Jenkins 2015 年 4 月 2 日
編集済み: A Jenkins 2015 年 4 月 2 日
function y = fcn(u)
persistent previous_u
if isempty(previous_u)
previous_u=0;
end
if u >= 0.5 && previous_u < 0.5
disp('Nose LG Door 2 Deployed')
end
previous_u=u;
y = u;

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by