开发者

Adding functions to GUI in Matlab

开发者 https://www.devze.com 2023-04-07 16:49 出处:网络
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.

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 t开发者_开发知识库o 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号