Filter löschen
Filter löschen

Appdesigner, knob value

5 Ansichten (letzte 30 Tage)
Furkan Karaman
Furkan Karaman am 20 Feb. 2023
Bearbeitet: Voss am 20 Feb. 2023
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.

Akzeptierte Antwort

Voss
Voss am 20 Feb. 2023
Bearbeitet: Voss am 20 Feb. 2023
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')
ans = logical
0
strcmp(value,'falling')
ans = logical
0
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.

Weitere Antworten (0)

Kategorien

Mehr zu Simulink Environment Customization finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by