Borrar filtros
Borrar filtros

Slider for Multiple Plots in GUIDE

11 visualizaciones (últimos 30 días)
Amanda
Amanda el 23 de Ag. de 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

Respuesta aceptada

Matt Fig
Matt Fig el 23 de Ag. de 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

Más respuestas (1)

Kye Taylor
Kye Taylor el 23 de Ag. de 2012
Something very similar that I've found helpful is available at
  1 comentario
Amanda
Amanda el 23 de Ag. de 2012
Everyone thanks. I'm good to go.

Iniciar sesión para comentar.

Categorías

Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by