0

I used simpletab.m from MatlabCentral to make simple tabs in GUI Matlab, now I wanted to add another function so that the result of the added function is displayed when I press the GUI tab buttons.

For example I want to add a function to every tab, when I press "tab 1" that function output (in this case a graph) is displayed.

Update 1

THANKS FOR YOUR PROMPT REPLY. It worked good, but what if I don't want to the "Tab 1 function" to appear when I press the Tab button..straight away I want my graphs to be properly listed when I press tab 1 button.

Update 2

I have written the modified function that you told me but still I get the tab name 'Tab 1 function' when I press the tab 1 button.

Moreover I want two sub tabs to appear straight under the tab 1 button when I press the tab 1 button..one sub tab will display data on one graph for all sensors and one tab will display data on individual graphs.

Do I have to write two separate functions and two separate subcall functions for each sub tab?

I hope you have understood what I am trying to say. I'm really running out of time..:(..feeling lost

1
  • Hello Khalid, welcome to Stack Overflow! When an answer is helpful, please don't say "Thanks" is your text - rather click the "up" arrow next to that answer to say "this was helpful" :-). Also, if an answer solves your problem, click on the checkmark to mark that answer as the accepted answer. Commented Sep 25, 2011 at 15:29

1 Answer 1

1

Simply add your function to the appropriate callback (see end of file):

% --- Executes on button press in tab1button.
function tab1button_Callback(hObject, eventdata, handles)

figure();
plot(1:10);


% --- Executes on button press in tab2button.
function tab2button_Callback(hObject, eventdata, handles)

disp('Button from Tab 2 was pressed')
figure();
plot(11:20);


% --- Executes on button press in tab3button.
function tab3button_Callback(hObject, eventdata, handles)

figure();
plot(11:20);

Now, if you press tab2, you'll see the message 'Button from Tab 2 was pressed' AND a new figure will open with a line going from 11:20. All you have to do now is to customize your plotting in the according callback function.

EDIT: I've modified 'tab1button_Callback' so that only the plotting function will be executed.

Sign up to request clarification or add additional context in comments.

4 Comments

I am not been able to make this GUI using Guide.Can it be made with guide?.I am not been able to highlight tab 1 and its subtabs when i press it, otherwise all the subtabs of the tab2 and tab 3 are also displayed along side
no need for guide. just copy & paste the file as posted in mathworks.com/matlabcentral/fileexchange/15193-simple-tab-panel/… and modify the end of the file as shown in my post.
I have written the modified function that you told me but still I get the tab name 'Tab 1 function' when I press the tab 1 button. Moreover I want two sub tabs to appear straight under the tab 1 button when I press the tab 1 button..one sub tab will display data on one graph for all sensors and one tab will display data on individual graphs. Do I have to write two separate functions and two separate subcall functions for each sub tab? I hope you have understood what I am trying to say. I'm really running out of time..:(..feeling lost..please feel free to advice and ask anything
any suggestions :(mathworks.com/company/newsletters/digest/july02/gui.html i have tried to implement this example but i cudnt do it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.