How to constantly update a plot off of a slider being pulled

조회 수: 163 (최근 30일)
Lawson Hoover
Lawson Hoover . 2012년 12월 11일
댓글: JP Schnyder . 2020년 1월 7일
Is it possible to automatically update a graph based off of the slider. I now how to update the graph once the position in the slider has changed, but what I want to know is it possible to have the graph up date as the slider is being pulled. Essentially, as the slider is being pulled, I want the graph to update for each position that the slider value cross, not just update once the slider is let go off and one set value is made. Does anyone have any ideas how to do this?
  댓글 수: 1
Srikanth Kothamasu
Srikanth Kothamasu 2016년 3월 10일
I have two curves one is actual like (y=mx^2),other one is simulated curve which will be having similar behavior but not follow the actual one. so now i have to fallow the first curve with the help of slider is that possible. if so can you help out.

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

채택된 답변

Teja Muppirala
Teja Muppirala 2012년 12월 11일
편집: John Kelly 님. 2013년 11월 19일
I know what you are trying to do, I often want to do the same
Save the following in a file and run it to see an example:
function myslider
x = 1:10;
hplot = plot(x,0*x);
h = uicontrol('style','slider','units','pixel','position',[20 20 300 20]);
addlistener(h,'ActionEvent',@(hObject, event) makeplot(hObject, event,x,hplot));
function makeplot(hObject,event,x,hplot)
n = get(hObject,'Value');
  댓글 수: 4
JP Schnyder
JP Schnyder 2020년 1월 7일
Since Matlab 2014a, 'ActionEvent' is renamed to 'ContinuousValueChange'in
addlistener(h,'ActionEvent',@(hObject, event) makeplot(hObject, event,x,hplot));

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

추가 답변 (1개)

Matt Fig
Matt Fig 2012년 12월 11일
편집: Matt Fig 님. 2012년 12월 11일
function [] = slider_plot()
% Plot different plots according to slider location.
S.fh = figure('units','pixels',...
'position',[300 300 300 300],...
S.x = 0:.01:1; % For plotting. = axes('unit','pix',...
'position',[20 80 260 210]);
S.LN = plot(S.x,S.x,'r'); = uicontrol('style','slide',...
'position',[20 10 260 30],...
'sliderstep',[1/20 1/20],...
function [] = sl_call(varargin)
% Callback for the slider.
[h,S] = varargin{[1,3]}; % calling handle and data structure.
  댓글 수: 3
Lawson Hoover
Lawson Hoover 2012년 12월 11일
Oh, ok, I was thinking that it had to do something with java. How hard would it be to do that? I have not really messed around with the java aspect of MATLAB yet.

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


Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by