Issue with Switch state in AppDesigner
6 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am migrating from GUIDE to Appdesigner and can't understand why Im getting an error
I have a switch that I want to change the color of a lamp component:
% Value changed function: VioletSwitch
function VioletSwitchValueChanged(app, event)
value = app.VioletSwitch.Value
if value=='On'
app.Lamp_V.Color='#b700ff';
else
app.Lamp_V.Color='r';
end
This works when the switch is on, but not when the switch is off, I get the following error message which I dont understand
value =
'Off'
Matrix dimensions must agree.
Error in Spectrometer/VioletSwitchValueChanged (line 174)
if value=='On'
0 件のコメント
回答 (1 件)
Cameron B
2020 年 1 月 16 日
編集済み: Cameron B
2020 年 1 月 16 日
function VioletSwitchValueChanged(app, event)
value = app.VioletSwitch.Value
if strcmpi(value,'On') == 1
app.Lamp_V.Color='g';
else
app.Lamp_V.Color='r';
end
2 件のコメント
Cameron B
2020 年 1 月 16 日
Yes, switch might be a better option for this. I edited my original response and replaced 'b700ff' with 'g'
参考
カテゴリ
Help Center および File Exchange で Install Products についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!