MATLAB: Problem with refreshdata in GUI

areaaxesdrawnowguiguideplotproblemrefreshdataset

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!

Best Answer

Sustitute inside the loop with:
set(s1,'Ydata',[h1(j) h1(j)])
set(s2,'Ydata',[h2(j) h2(j)])
pause(.1)