MATLAB: Hi, I have 4 axes and only one push button, all the axes work but they only start once the last one is finished, is there any way I make them all work at the same time

axesguide

so far I have this in my push button Callback
A=str2num(get(handles.A,'String'));
T=str2num(get(handles.T,'String'));
m=str2num(get(handles.m,'String'));
k=str2num(get(handles.k,'String'));
A4=str2num(get(handles.A4,'String'));
A0=str2num(get(handles.A0,'String'));
A2=1/T;
A3=sqrt(k/m);
t=0:1/10:60;
axes(handles.axes2)
for i=1:1:601
x(i)=A0+A*exp(-A2.*t(i)).*cos(A3.*t(i)-A4);
plot(t(i),x(i),'.b')
axis([0 60 min(x)-1 max(x)+1])
hold on
pause(0.001)
end
axes(handles.axes3)
for i=1:1:601
v(i)=-A*exp(-A2.*t(i)).*(A2*cos(A3.*t(i)-A4)+A3*sin(A3.*t(i)-A4));
plot(t(i),v(i),'.r')
axis([0 60 min(v)-1 max(v)+1])
hold on
pause(0.001)
end
axes(handles.axes4)
for i=1:1:601
a(i)=A*A2*exp(-A2.*t(i)).*(A2*cos(A3.*t(i)-A4))+A*exp(-A2.*t(i)).*(A2*A3*sin(A3.*t(i)-A4)+(A3.^2)*sin(A3.*t(i)-A4));
plot(t(i),a(i),'.c')
axis([0 60 min(a)-1 max(a)+1])
hold on
pause(0.001)
end
axes(handles.axes1)
for i=1:1:601;
x(i)=A0+A*exp(-A2.*t(i)).*cos(A3.*t(i)-A4);
y(i)=0.25;
plot(x(i),y(i),'.b','MarkerSize',20)
axis([min(x)-1 max(x)+1 0 0.5])
pause(0.001)
end
Any help is appreciated

Best Answer

Don't put plot inside the loop. Put all plots outside the loops and don't use index (i). For example:
plot(x,y,'.b','MarkerSize',20)
Repeat for the other plots.
Related Question