function [] = animate(x, plot1, n1, style1, plot2, n2, style2, t, xtitle, ytitle, gtitle); yes = 'y'; plotans = 'y'; scale1 = 1.; scale2 = 1.; style1i = style1; style2i = style2; style1i(1) = 'i'; style2i(1) = 'i'; style11 = style1(1); style21 = style2(1); while yes == plotans speed = input(' enter animation speed factor: '); temp(1) = scale1 * max(max(abs(plot1))); temp(2) = scale2 * max(max(abs(plot2))); ymax = max(temp); temp(1) = scale1 * min(min(plot1)); temp(2) = scale2 * min(min(plot2)); ymin = min(temp); xmin = min(x); xmax = max(x); xmin = xmin - .05*abs(xmax-xmin); xmax = xmax + .05*abs(xmax-xmin); ymin = ymin - .05*abs(ymax-ymin); ymax = ymax + .05*abs(ymax-ymin); hold off; [utimes1, uvals] = size(plot1); [utimes2, uvals] = size(plot2); utimes = max(utimes1,utimes2); for j = 1:utimes-1 j1 = min(j,utimes1); j2 = min(j,utimes2); ps1 = scale1*plot1(j1, 1:n1); ps2 = scale2*plot2(j2, 1:n2); h=plot(x,ps1,style1,x,ps1,style11,x,ps2,style2,x,ps2,style21); if( j == 1) xxmin = xmin-0.1*(xmax-xmin); xxmax = xmax+0.1*(xmax-xmin); yymin = ymin-0.1*(ymax-ymin); yymax = ymax+0.1*(ymax-ymin); xloc = xxmin - .05*(xxmax-xxmin); yloc = yymax + .05*(yymax-yymin); axis([ xxmin xxmax yymin yymax]); title(gtitle); xlabel(xtitle); ylabel(ytitle); hold on; end; h1 = text(xloc,yloc,['TIME = ', num2str(t(j))] ); pause(.01/speed); delete(h); delete(h1); end ps1 = scale1*plot1(utimes1,1:n1); ps2 = scale2*plot2(utimes2,1:n2); h = plot(x,ps1,style1,x,ps1,style11,x,ps2,style2,x,ps2,style21); h1 = text(xloc,yloc,['TIME = ', num2str(t(utimes))] ); plotans = input(' Plot results again? '); if( plotans == 'y' ) delete(h); delete(h1); scale1 = input(' Enter scale factor for plot 1: '); scale2 = input(' Enter scale factor for plot 2: '); end end hold off;