How to plot in uitabgroup simultaneously

1 view (last 30 days)
Indah Nurina
Indah Nurina on 8 Feb 2016
Answered: Adam on 8 Feb 2016
Suppose I have 3 functions
  1. f(x)=2x+4
  2. h(x)=2x+5
  3. g(x)=2x+6
I have 3 uitabs which belong to each function.
When user input the X data using uitable,for each uitab, I want to see something like this:
1st uitab:
plot (X,2.*X+4);
2nd uitab:
plot (X,2.*X+5);
3rd uitab:
plot (X,2.*X+6);
My question:
1.How to plot the graph simultaneously to each uitab?
2.And how to make sure that when user change the input, the new graph will be shown and not overlap with the old one?
Thanks!!

Answers (1)

Adam
Adam on 8 Feb 2016
Why do you have functions owning tabs? Or am I just misunderstanding your meaning?
If you have kept the handles of all three of your tabs in your tab group then you can just refer your plot instructions to axes positioned in each of those tabs.
To follow the example in the help documentation you would have e.g.
f = figure;
tabgp = uitabgroup(f,'Position',[.05 .05 .3 .8]);
tabs(1) = uitab(tabgp,'Title','Function f');
tabs(2) = uitab(tabgp,'Title','Function g');
tabs(3) = uitab(tabgp, 'Title', 'Function f' );
Then you can just create an axes on each tab in whatever way you need it, using the 'Parent' property to define which tab the axes are in and store all 3 axes handles.
Then in some other code that triggers your functions just plot them on the relevant axes. If you want to add data to an axes rather than replace then use e.g.
hold( hAxes(1), 'on' )
where hAxes(1) is your axes handle from an array of handles.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!