Control App designer lamp from Matlab script

1 回表示 (過去 30 日間)
Alex kew
Alex kew 2018 年 4 月 30 日
回答済み: Dinesh 2023 年 3 月 6 日
Hi, everyone.
I have designed an app with a start button and a lamp called NSg. when I click the start button, its callback function will call this code in my Matlab Script:
function disableLamp()
app.NSgLamp.Enable = 'off';
disp("works");
end
however, this (app.NSgLamp.Enable = 'off') seems does not work for me, can anyone tell me how to do this. Thanks a lot.
  1 件のコメント
Kendall Knight
Kendall Knight 2019 年 4 月 17 日
Can you give some more information?

サインインしてコメントする。

回答 (1 件)

Dinesh
Dinesh 2023 年 3 月 6 日
Hi Alex.
  1. Firstly, make sure that NSgLamp object is correctly defined in App designer or not.
  2. Check if the callback for when the start button is defined correctly and also see if disableLamp() function is called in it.
  3. If the line "app.NSgLamp.Enable = 'off'" still doesn't work, then you can try replacing it with the following line of code:
set(app.NSgLamp, 'Enable', 'off');
This is the complete code for the updated function:
function disableLamp(app)
set(app.NSgLamp, 'Enable', 'off');
disp("works");
end
If you have already tried these steps and are still having issues, please provide more information about the error message you are receiving or the behavior you are observing.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by