display a value in edit text in GUI
Ältere Kommentare anzeigen
I had an array with 3 elements, I want to display each of them in 3 edit text boxs. Please guide me how to do this?
Akzeptierte Antwort
Weitere Antworten (2)
Walter Roberson
am 15 Okt. 2011
eh1 = uicontrol('Style','edit','Position', POSITION1);
eh2 = uicontrol('Style','edit','Position', POSITION2);
eh3 = uicontrol('Style','edit','Position', POSITION3);
set(eh1, 'String', num2str(YourArray(1)));
set(eh2, 'String', num2str(YourArray(2)));
set(eh3, 'String', num2str(YourArray(3)));
Here, the POSITION1 etc would be 4-element vectors giving the position and size you want for that particular edit box. For example,
POSITION1=[1/3, 1/2, 1/4, 1/5];
This would mean that the bottom left corner of the uicontrol should be positioned 1/3 of the way from the left border of the figure, 1/2 of the way up from the bottom of the figure, and that the width of the control should be 1/4 of the figure (so the right edge would be 1/3+1/4) and the height of the control should be 1/5 of the figure (so the top edge would be 1/2+1/5.)
You may have noticed in the above that the coordinates were "normalized", expressed as fractions of the height or width. That can work well for positioning the bottom corner of the figure if you do not know exactly (to the pixel) how big the figure is, such as if you want to support the user resizing the figure. On the other hand, using fractions for the width and height is usually a recipe for a mess.
There are other ways of specifying what the position coordinates designate, which you can invoke by using a 'Units' parameter before the Position, such as
uicontrol('Style','edit','Units', 'points', 'Position', [76,189,157,24])
That would start 76 points across, 189 points up, and would be 157 points wide and 24 points high. 1 point is 1/72 of an inch.
1 Kommentar
Du Tran
am 17 Okt. 2011
kyaw zaw
am 7 Dez. 2017
0 Stimmen
I want to show result data that is shown in simulink Display block in GUI edit box. How can i solve?
Kategorien
Mehr zu Characters and Strings finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!