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

Adam Danz
Adam Danz 2019년 12월 5일
편집: Adam Danz 2020년 1월 28일
What's your question?
NOTE: The user "Matlab" has deleted their comments within this discussion.
Adam Danz
Adam Danz 2019년 12월 6일
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 2019년 12월 6일
I think I got it. See my answer.

댓글을 달려면 로그인하십시오.

 채택된 답변

Adam Danz
Adam Danz 2019년 12월 6일
편집: Adam Danz 2019년 12월 6일

1 개 추천

"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

Life is Wonderful
Life is Wonderful 2019년 12월 6일
I was exactly thinking the same !! Let me try
Life is Wonderful
Life is Wonderful 2019년 12월 6일
편집: Life is Wonderful 2019년 12월 6일
Getting some problem in setting the figure . ONLY one figure is open ( that is from Design view in canvas.If I give fig =uifigure(); . New figure is generated . I want same figure ... some how unable to locate the handler for the figure. Can you please provide the input . Thanks !!
get(uit)
BackgroundColor: [3×3 double]
BeingDeleted: 'off'
BusyAction: 'queue'
ButtonDownFcn: ''
CellEditCallback: [function_handle]
CellSelectionCallback: [function_handle]
Children: [0×0 handle]
ColumnEditable: []
ColumnFormat: {}
ColumnName: {11×1 cell}
ColumnSortable: 1
ColumnWidth: 'auto'
CreateFcn: ''
Data: [857×11 table]
DeleteFcn: ''
DisplayData: [857×11 table]
DisplayDataChangedFcn: [function_handle]
Enable: 'on'
Extent: [0 0 0 0]
FontAngle: 'normal'
FontName: 'Helvetica'
FontSize: 12
FontUnits: 'pixels'
FontWeight: 'normal'
ForegroundColor: [0 0 0]
HandleVisibility: 'on'
InnerPosition: [6 52 422 260]
Interruptible: 'on'
KeyPressFcn: ''
KeyReleaseFcn: ''
Layout: [0×0 matlab.ui.layout.LayoutOptions]
OuterPosition: [6 52 422 260]
Parent: [1×1 Panel]
Position: [6 52 422 260]
RearrangeableColumns: 'off'
RowName: 'numbered'
RowStriping: 'on'
StyleConfigurations: [0×3 table]
Tag: ''
Tooltip: ''
Type: 'uitable'
UIContextMenu: [0×0 GraphicsPlaceholder]
Units: 'pixels'
UserData: []
Visible: 'on'
Adam Danz
Adam Danz 2019년 12월 6일
편집: Adam Danz 2019년 12월 6일
Please read the comments I wrote next to that line of code.
The first input to uiconfirm() is your app's figure handle.
Life is Wonderful
Life is Wonderful 2019년 12월 6일
Silly question , So how to know app figure handle ?
Adam Danz
Adam Danz 2019년 12월 6일
It's usually listed at the top of the component browser in AppDesigner.
In the image below, my app figure handle is app.MyAppUIFigure
191206 005628-App Designer - C__Users_adanz_Documents_MATLAB_savehere_my templates_myFakeApp.m.png
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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2019년 12월 5일

댓글:

2020년 2월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by