×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

matlab gui

matlab gui

matlab gui

(OP)
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..

RE: matlab gui

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...
  

RE: matlab gui

(OP)
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..:)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources