Problem with refreshdata in GUI

4 vues (au cours des 30 derniers jours)
Kostbone
Kostbone le 25 Août 2011
heya, i know there is similar question as mine, but i couldnt use it for solution
So ill try to ask you base on my problem
First of all i made animation in script(m file), and it works perfectly, but i want to embedd it in GUI, and then problems started
I want to get animation in axes plot, and simply i dont know how to use refreshdata properly or maybe problem is somewhere else
This is part of code:
axes(handles.axes3)...
lines of code to draw something on axes (it works)
...
vel=length(evalin('base','h1'));
h1=evalin('base','h1');
h2=evalin('base','h2');
h10=evalin('base','h10');
h20=evalin('base','h20');
x1=[0.1 0.1+z1];
y1=[h10 h10];
x2=[0.1+z1+0.2 z1+0.1+0.2+z2];
y2=[h20 h20];
s1=area(x1,y1);
s2=area(x2,y2);
set(s1,'YDataSource','y1')
set(s2,'YDataSource','y2')
for j=1:vel
y1=[h1(j) h1(j)];
y2=[h2(j) h2(j)];
refreshdata
drawnow
end
As you can see, i have to get datas from Workspace, so i can use them in loop, and so i can use them to draw in axes plot.
So basicly i want that "area" function to be redrawn, each iteration of loop
Just to introduce in code:
h1 and h2 are arrays of about 300 datas, z1 and z2 are just datas for drawing
i think everything else is clear, also if you need more code or more infos pls write me, since i really dont know how to solve this problem
Thank you in advance!

Réponse acceptée

Oleg Komarov
Oleg Komarov le 25 Août 2011
Sustitute inside the loop with:
set(s1,'Ydata',[h1(j) h1(j)])
set(s2,'Ydata',[h2(j) h2(j)])
pause(.1)
  2 commentaires
Kostbone
Kostbone le 25 Août 2011
ty very much it works perfectly, but if you have time and will, can you explain me why my source code didnt work inside gui, but it worked as standalone m file?
Sry for bothering but i just want to learn basics properly :)
Oleg Komarov
Oleg Komarov le 25 Août 2011
Try refreshdata(object_handles,'caller')

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by