Slider for Multiple Plots in GUIDE

9 Ansichten (letzte 30 Tage)
Amanda
Amanda am 23 Aug. 2012
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

Akzeptierte Antwort

Matt Fig
Matt Fig am 23 Aug. 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

Weitere Antworten (1)

Kye Taylor
Kye Taylor am 23 Aug. 2012
Something very similar that I've found helpful is available at

Kategorien

Mehr zu Migrate GUIDE Apps finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by