what command or box do i use to get a dynamic input box on app design GUI
20 ビュー (過去 30 日間)
I am trying to find a command or input box where I can make dynamic inputs to plort on the graph. I want it to take in the value of the no of sensors in rthe GUI and the then open an input box asking for the coorinates of each sensor
for example :-
No of sensors= 3
an input box asking for 3 sets of X and Y coordinates to plot on the graph
No of sensors= 4
an input box asking for 4 sets of X and Y coordinates to plot on the graph
Walter Roberson 2021 年 7 月 5 日
You are using App Designer, so you are probably using uifigure() as your base.
So you can have your code call uieditfield() to dynamically place an edit box onto the container. https://www.mathworks.com/help/matlab/ref/uieditfield.html
You can configure its ValueChangedFcn https://www.mathworks.com/help/matlab/ref/matlab.ui.control.numericeditfield-properties.html#buh_e24-76_sep_shared-ValueChangedFcn to invoke a callback when the user enters data into it. Or not, if you have some other way for the user to invoke action (which is probably the case since you want the user to enter in all the values before doing anything.)
If you do configure a callback, you would provide the handle to a function that you had already written. You would not try to write callback code dynamically! Instead, have all of the fields use the same callback code, with the callback distinguishing between the fields by their Tag or by some UserData you attached to the field.
If you do not have a maximum number of sensors that the user can enter, then you need to design in some kind of scroll box for the inputs. But if you are headed towards that, then uitable() is often an easier approach.
If you have a small fixed maximum number of sensors, then often the easiest approach is to design all of them with positions and callbacks and whatever ahead of time, but set them all to be invisible at the start, and then turn on only as many as need. This does not involve creating any objects dynamically, just making existing objects visible or invisible.
その他の回答 (1 件)
Jai Khurana 2021 年 7 月 2 日