How can I animate the drawing of a figure 8 shape in a polar plot to confirm the path it takes?
    2 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Omar Ahmed
 am 20 Jun. 2018
  
    
    
    
    
    Kommentiert: Omar Ahmed
 am 20 Jun. 2018
            Here is my code, where I am taking a figure 8 shape on a polar plot and rotating it around. I want to confirm the path that each figure 8 is drawn by animating it.
start = 0;
end_ = 2*pi;
disc = pi/16;
theta4 = 0:0.01:2*pi;
rho4 = sqrt(4*cos(2*theta4).*(sec(theta4).^4)); % figure 8 function
for i=0:31;
    interval = start+i*disc:0.01:end_+i*disc;
    %subplot(4,4,i+1)
    polarplot(interval,rho4)
    hold on
    pause(0.2)
end
0 Kommentare
Akzeptierte Antwort
  Steven Yeh
      
 am 20 Jun. 2018
        Try this:
start = 0;
end_ = 2*pi;
disc = pi/16;
theta4 = 0:0.01:2*pi;
rho4 = sqrt(4*cos(2*theta4).*(sec(theta4).^4)); % figure 8 function
figure()
stepSize = 20;
for i=0:31
    interval = start+i*disc:0.01:end_+i*disc;        
    for k = 1:stepSize:length(rho4) 
        endPoint = min(k+stepSize, length(rho4)); % avoid array boundary exception
        polarplot(interval(k:endPoint), rho4(k:endPoint));
        hold on    
        pause(0.2)
    end
end
The stepSize variable used to set the speed of the animation
You can set the color in the outer i loop
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Animation finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

