필터 지우기
필터 지우기

Slider for Multiple Plots in GUIDE

조회 수: 11 (최근 30일)
Amanda
Amanda 2012년 8월 23일
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

채택된 답변

Matt Fig
Matt Fig 2012년 8월 23일
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

추가 답변 (1개)

Kye Taylor
Kye Taylor 2012년 8월 23일
Something very similar that I've found helpful is available at
  댓글 수: 1
Amanda
Amanda 2012년 8월 23일
Everyone thanks. I'm good to go.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Specifying Target for Graphics Output에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by