Hi! I am creating a gui (using GUIDE) that will display an animation that changes in response to the user’s mouse-click input. In order to update the animation at regular intervals, I have created a timer function that plots 1 updated frame of the animation each time it is called. There is only 1 axes on the gui, and its name is ArmAxes.
The problem I’m having is that the only way, so far, that I’ve been able to successfully animate within the timer function is to use the handles structure, as follows:
function animation_timer_fcn(hObject, events,figure_handle)
…
% update x & y values …
…
% plot 1 frame of animation
plot(handles.ArmAxes,x,y);
drawnow;
Although the animation displays correctly using this code, unfortunately the use of the handles structure in this timer function interferes with my (necessary) use of the handles structure elsewhere in my gui m-file, and it is causing many different bugs and data problems.
I’m trying to determine whether there is an alternative way to animate within the timer function, that doesn’t use the handles structure. Here are the options I’ve investigated:
a) line_handle = handles.ArmAxes;
set(line_handle,x,y);
set(line_handle,'erasemode','xor');
drawnow;
b) line_handle = plot(x,y,'r-','LineWidth',2);
set(line_handle,'erasemode','xor');
drawnow;
-- Both of these options eliminate all of the data problems I had been having when animating using the handles structure, BUT neither option produces any animation.
I have read in various places that using the plot( ) command isn’t efficient, and that using set(axes_handle,’erasemode’,’xor’) is much quicker and more efficient. However, so far, this code hasn’t worked to actually produce animation.
Any suggestions about how I can animate within my timer function, without using the handles structure (and, maybe, also avoiding the plot( ) command?)? Thanks!!
|
|
0
|
|
|
|
Reply
|
Kate
|
3/3/2010 8:50:20 PM |
|
Anyone have any experience with this problem? Thanks!
|
|
0
|
|
|
|
Reply
|
Kate
|
3/8/2010 9:50:24 PM
|
|
Any ideas?
|
|
0
|
|
|
|
Reply
|
Kate
|
3/11/2010 4:26:21 PM
|
|
Hi Kate J.
I got more or less the same problem. I found this example on the net:
x = 0:.1:8;
y = 0:.1:8;
h = plot(x,y);
set(h,'YDataSource','y')
set(h,'XDataSource','x')
pause(2);
x = 8:.1:18;
y = 8:.1:18;
refreshdata
This is working in an single matlab file but I'm not able to make it work in GUIDE.
function StartMovie(handles, RenderXdata, RenderYdata)
sizeRenderXdata = size(RenderXdata);
XXData = 1;
YYData = 1;
h1 = plot(handles.axes1,XXData,YYData);
set(h1,'XDataSource','XXData');
set(h1,'YDataSource','YYData');
for i=1:length(RenderXdata)
% tic;
for t=1:sizeRenderXdata(2)
XXData = RenderXdata{i,t};
YYData = RenderYdata{i,t};
refreshdata
end
end
end
My GUI is having problems with this function. No response on my axes1 figure. What can be wrong??
I found something about the HandleVisibility in a forum but this did not work for me.
|
|
0
|
|
|
|
Reply
|
sjoerdvanelp (1)
|
3/14/2010 8:40:19 PM
|
|
|
3 Replies
240 Views
(page loaded in 0.244 seconds)
Similiar Articles: Question about animating in GUI timer function - comp.soft-sys ...Hi! I am creating a gui (using GUIDE) that will display an animation that changes in response to the user’s mouse-click input. In order to updat... Using waitbar while calling a time consuming function in a GUI ...I have a button in my GUI which has to call a function that takes a very ... Post Question | ... A waitbar in conjunction with a timer callback ... timer function in GUIDE - comp.soft-sys.matlab... some stuff using handles, updating display etc end The question is how to pass the GUI ... Passing Data - comp.soft-sys ..... when GUI is closed and timer function in GUI ... GUI, timer, handles - comp.soft-sys.matlab... Post Question ... GUI, timer, handles - comp.soft-sys.matlab Hi ... for Graphic User Interface ... objects show ... when GUI is closed and timer function in GUI ... How to make a stopwatch run in matlab gui? - comp.soft-sys.matlab ...... in MATLAB. I have few questions. ... when GUI is closed and timer function in GUI ... How to make a stopwatch run in matlab gui ... Question on the usage of SetAppData - comp.soft-sys.matlab ...timer function in GUIDE - comp.soft-sys.matlab... refresh some stuff using handles ... Browse other questions tagged gui matlab ui-guidelines or ask your own question. GUI handles - not object handles - comp.soft-sys.matlab... Post Question | Groups ... GUI, timer, handles - comp.soft-sys.matlab timer function in GUIDE - comp.soft-sys.matlab GUI handles - not ... Can I interrupt a running GUI callback? - comp.soft-sys.matlab ...... Post Question | Groups ... could I read the A/D board in a periodic timer function? ... GUI, timer, handles - comp.soft-sys.matlab GUI, timer ... display a clock in a gui matlab in textbox? - comp.soft-sys.matlab ...... Post Question | Groups ... > > > > > function [] = GUI_clock() > % Demonstrate how to have a ... GUI, timer, handles - comp.soft-sys.matlab display a ... Calling VB script from Matlab GUI - comp.soft-sys.matlab ...timer function in GUIDE - comp.soft-sys ... soft-sys.matlab Hi ... for Graphic User Interface ... ... and Matlab code from LabVIEW GUI ... programming.itags.org: LabVIEW question ... Question about animating in GUI timer function - comp.soft-sys ...Hi! I am creating a gui (using GUIDE) that will display an animation that changes in response to the user’s mouse-click input. In order to updat... Question about animating in GUI timer function - Newsreader ...Hi! I am creating a gui (using GUIDE) that will display an animation that changes in response to the user’s mouse-click input. In order to update the animation at ... 7/30/2012 3:39:11 PM
|