Slider for Multiple Plots in GUIDE
9 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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
0 个评论
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!