IF statement not executing
Mostrar comentarios más antiguos
% Value changed function: ActionDropDown_2
function ActionDropDown_2ValueChanged(app, event)
if app.ActionDropDown_2.Value == "Plot"
app.Tbl = app.UITable2.Data(:,{'DATE', 'AVAILABILITY'});
app.X = app.UITable2.Data(:,3);
app.Y = app.UITable2.Data(:,31);
plot(app.UIAxes,app.X,app.Y)
end
end
The callback function operates as expected, once called, the debug arrow reaches breakpoint of the IF statment line but once I chose to "Continue" the debug arrow jumps straight to END. Not executing any of the following lines to define Tbl, X, or Y and no plot.
6 comentarios
shnrndll
el 5 de En. de 2022
Voss
el 5 de En. de 2022
Seems like app.ActionDropDown_2.Value is not equal to "Plot".
shnrndll
el 5 de En. de 2022
Cris LaPierre
el 5 de En. de 2022
The code is syntatically correct, and you are not getting any errors. The issue is that the condition evaluates as false, so the code inside the statement does not get run.
shnrndll
el 5 de En. de 2022
Walter Roberson
el 5 de En. de 2022
Put a breakpoint at the if. When you arrive there, command
class(app.ActionDropDown_2.Value)
if char(app.ActionDropDown_2.Value)
disp('char')
disp(double(app.ActionDropDown_2.Value))
elseif isstring(app.ActionDropDown_2.Value)
disp('string')
disp(double(app.ActionDropDown_2.Value{1}))
else
disp('other')
disp(app.ActionDropDown_2.Value)
end
and tell us what the output is.
This is not intended as permanent code: it is only intended to help debug the problem.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Develop Apps Using App Designer en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!