UIFigure Keyboard control update

2 visualizaciones (últimos 30 días)
Life is Wonderful
Life is Wonderful el 5 de Dic. de 2019
Comentada: Life is Wonderful el 11 de Feb. de 2020
I have a input for my uifigure for plotting the data
PlotCntrl = input('+: cont, -: back, a=: auto, q: quit -->', 's')
I need help . My Code is available in the below link
Question : How to apply PlotCntrl = input('+: cont, -: back, a=: auto, q: quit -->', 's') in a App design ?
  3 comentarios
Adam Danz
Adam Danz el 6 de Dic. de 2019
I'm not sure what you mean by "input". input() is a Matlab function that prompts the user to enter information. The line in your question works but the one in your comment above doesn't because of the axis handle provided in the input.
Sorry, I have no idea what you're trying to do but I'd be happy to help if you can explain it.
Adam Danz
Adam Danz el 6 de Dic. de 2019
I think I got it. See my answer.

Iniciar sesión para comentar.

Respuesta aceptada

Adam Danz
Adam Danz el 6 de Dic. de 2019
Editada: Adam Danz el 6 de Dic. de 2019
"I am looking for an approach on how to provide the input control for the uifigure"
Idea 1: add buttons to your App
One approach would be to simply add 4 buttons to your App.
  • Continue
  • Back
  • Auto
  • Quit
Each button could use the same callback function that changes x (or whatever other variables they should affect) depending on which button was pressed.
Idea 2: use uiconfirm()
uiconfirm(f,message,title,Name,Value) is a dialog box that allows the user to select a button option which is returned as an output. Try this.
app.UIFigure = uifigure(); % This is your app, you don't need this line.
selection = uiconfirm(app.UIFigure,'Select something','MyApp',...
'Options',{'Continue','Back','Auto','Quit'}, ...
'DefaultOption','Continue', ...
'CancelOption','Quit');
  7 comentarios
Adam Danz
Adam Danz el 6 de Dic. de 2019
I'm glad I can help!
Here are some suggestions for improvement
1) I think this looks better and is easier to read:
msg = '[+] cont, [-] back, [a] auto, [q] quit';
2) Instead of a bunch of strcmp()... elseif strcmp().... use a switch-case.
% instead of this....
if strcmp(PlotCntrl, 'a')
mode = 'auto';
elseif strcmp(PlotCntrl, 'q')
x = 0;
elseif strcmp(PlotCntrl, '-')
if x>1, x=x-3; end
else
if x<xend-1, x=x+1; end
end
% I recommend this.....
switch plotCntrl
case 'a'
mode = 'auto';
case 'q'
x = 0;
case '-'
if x>1, x=x-3; end
otherwise
if x<xend-1, x=x+1; end
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Develop uifigure-Based Apps en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by