Has anyone found Lamp enable and disable in appdesigner?

조회 수: 6 (최근 30일)
AJEET KUMAR
AJEET KUMAR 2020년 8월 24일
댓글: AJEET KUMAR 2020년 8월 28일
Hello,
I am trying to enable and disable lamp after pause(1), i.e. one second interval.
by this:
ps = 10;
n = 1;
while (ps == 10)
fprintf('Hi!.\n');
app.Lamp2.Enable = 0;
app.Lamp3.Enable = 0;
pause(n);
app.Lamp2.Enable = 1;
app.Lamp3.Enable = 1;
end
It prints Hi! after each secon in the command window, but doesn't show the flasing the lamp. I tried changing the pause value to different values like 0.5, 1, 2 etc.
Still couldn't get output.
Also, I get sometime error like,
Invalid or deleted object., Just after the pause(1) line.
Can some plese suggest me into this?
Thank you

채택된 답변

Geoff Hayes
Geoff Hayes 2020년 8월 25일
Ajeet - try using "on" or "off" (instead of 1 or 0) and add a pause after each change to the enabled property (so that there is a period of time for the lamp to be in that on or off state).
while (ps == 10)
fprintf('Hi!.\n');
app.Lamp2.Enable = 'off';
app.Lamp3.Enable = 'off';
pause(n);
app.Lamp2.Enable = 'on';
app.Lamp3.Enable = 'on';
pause(n);
end
  댓글 수: 1
AJEET KUMAR
AJEET KUMAR 2020년 8월 28일
Thank you for reminding about the last pause. However 1, 0 works as on and off. Anyway good to have more options.
Thanks Ajeet

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by