Appdesigner, knob value
5 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have an oscilloscope-App in which I want to use 2 knobs , if I switch the knob a value to a variable should be assigned. And this value should be used in a function if a button is then pressed.
That works with one knob but not with the other. I have absolutely no idea why that is.
Does anyone have a clue?
from the appdesigner code:
function EdgeKnobValueChanged(app, event)
value = app.EdgeKnob.Value;
if strcmp(value,'rising')
app.Edge=2;
end
if strcmp(value,'falling')
app.Edge=1;
end
end
% Value changed function: CouplingKnob
function CouplingKnobValueChanged(app, event)
value = app.CouplingKnob.Value;
if strcmp(value,'AC')
app.AC=1;
app.DC=0;
end
if strcmp(value,'DC')
app.DC=1;
app.AC=0;
end
end
function StartButtonPushed(app, event)
if strcmp(app.Trigger,'Simple edge')
somefunction(app.Edge); %the value for app.Edge cant be used in the function
end
end
I would be really grateful for any kind of help.
0 件のコメント
採用された回答
Voss
2023 年 2 月 20 日
編集済み: Voss
2023 年 2 月 20 日
uiknob 'Value' is a numeric (https://www.mathworks.com/help/matlab/ref/matlab.ui.control.knob-properties.html), so both strcmp calls return false, so app.Edge is not set.
value = 3; % some numeric value
strcmp(value,'rising')
strcmp(value,'falling')
Regardless of that, you should initialize app.Edge, app.AC, and app.DC in your startupFcn to be the values corresponding to their repective knobs, in case the user clicks the start button without interacting with the knobs.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Simulink Environment Customization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!