r = 1; hmax = 28; n = 1000;h = linspace(0,hmax,n);t = linspace(0,360,n);k = 0;pt = 1/6000;x = zeros(length(h),length(t));vx = x;y = x;vy = y;a = r+h;b = r+hmax/2*(cosd(t).^2)+hmax/2;for i = 1:n x(i,:) = a(i)+r.*cosd(t); y(i,:) = b(i)+r.*sind(t); vx(i,:) = r+r.*cosd(t); vy(i,:) = r+h.*sind(t);endfigure(3)ball_bounce1= plot(x,y,'c');axis([-1 31 -1 31])grid on while k < 10 if rem(k,2) == 0 for i = 1:n set(ball_bounce1,'XData',x(i,:),'YData',y(i,:)); pause(pt) end end if k > 10 break end end
MATLAB: How can i make this animation faster in MATLAB
animationMATLAB
Related Question
- Concurrent interaction using functions
- I’m trying to take the grid points x and y and the velocities Vx and Vy to plot the streamlines using streamline starting at x = −4 and 21 and y locations between -4 and 4.
- I am getting a parse error on the = sign in the third line but i cant seem to figure out why. Any suggestions and or solutions? Thanks
Best Answer