Slider for Multiple Plots in GUIDE
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I need to be able to scroll through 10 graphs on a single
axis in GUIDE. I don't know where to start.
So the widgets I'm using is one axis, slider, and pushbutton for access
to axis.
So for push button 1:
I plot 10 different plots on the same data.
Now I want it to be able to scroll through each plot.
I really don't know where to begin on this. A code example
would be appreciated.
Thanks,
Amanda
0 commentaires
Réponse acceptée
Matt Fig
le 23 Août 2012
Here is a simple example GUI. Note that the same principle applies in GUIDE.
function [] = slider_plot()
% Plot different plots according to slider location.
S.fh = figure('units','pixels',...
'position',[300 300 300 300],...
'menubar','none',...
'name','slider_plot',...
'numbertitle','off',...
'resize','off');
S.x = 0:.01:1; % For plotting.
S.ax = axes('unit','pix',...
'position',[20 80 260 210]);
plot(S.x,S.x,'r');
S.sl = uicontrol('style','slide',...
'unit','pix',...
'position',[20 10 260 30],...
'min',1,'max',3,'val',1,...
'sliderstep',[1/2 1/2],...
'callback',{@sl_call,S});
function [] = sl_call(varargin)
% Callback for the slider.
[h,S] = varargin{[1,3]}; % calling handle and data structure.
cla
switch round(get(h,'value'))
case 1
cla
plot(S.ax,S.x,S.x.^1,'r')
case 2
cla
plot(S.ax,S.x,S.x.^2,'b')
case 3
cla
plot(S.ax,S.x,S.x.^3,'k')
otherwise
disp('cannot plot')
end
0 commentaires
Plus de réponses (1)
Voir également
Catégories
En savoir plus sur Migrate GUIDE Apps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!