Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

matlab gui

Status
Not open for further replies.

liana81

Mechanical
Joined
Mar 26, 2007
Messages
2
Location
GR
Hello to everyone, i am a newbie in this forum as well as in matlab programming, that's why my question is simple.
I have made with Guide a panel which has 10 pushbuttons, one for each number between 0-9.When i press a button i.e. the 1,i want this number to be displayed.When i press the button 2, the number 2 must be displayed e.t.c.Generally all the numbers must be displayed from the beginning.I have understood that this can be done with the callback of each pussbutton,but i 'don't know how.What commands should i use;
If anyone helped me, i would be really grateful..
 
Lets say that you have 1 text box where you want to display the number of the selected pushbutton called textbox1.

First, remove the panel and put all of the pushbuttons in a button group. You can do it the other way but it is more of a pain. Lets call the button group pushbtngrp (and the pushbuttons pb0 - pb9). Then the following code should do what you want:

function pushbtngrp_SelectionChangeFcn(hObject, eventdata, handles)
selection = get(handles.pushbtngrp,'SelectedObject');
switch get(selection,'Tag')
case 'pb0'
value = 0;
case 'pb1'
value = 1;
case 'pb2'
value = 2;
...

end
set(handles.textbox1,'String',value);

hope this helps...
 
First of all,thank you for your answer.Secondly,when you say textbox,which component do you mean;The edit text;Do i have to write something in its callback;Or just the code you gave me;
I don't know much about guide and unfortunatelly i don't have the time to learn it.So excuse me if my questions are fullish..:)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top