pause button not working
Afficher commentaires plus anciens
hey all
ive been trying to use the pause function in MTLAB to achieve a cool animation effect for my projectle motion code. it hasnt been working, can anyone help me out?
thanks!
clear , clc
g=9.8;
ang=input('Enter incident angle: ');
if (ang<=0)
disp('Illegal Input')
end
v=input('Enter speed(m/s): ');
if (v<=0)
disp('Illegal Input')
end
disp('enter air resistance below. If you enter 0 or a negative number, it will be automatically .5')
disp('To find the coeficient of air resistace multiply air density, drag,area times .5')
air=input('Enter air resitiance (Will otherwise be .5): ');
if air<=0,' ';
air=.5;
end
vx0=v*cosd(ang)-air*cosd(ang);%Calculation fro air resitance
vy0=v*sind(ang)-air*sind(ang);
t=(0:.01:10000);
height=vy0*t-.5*g*t.^2;
land=find(height>=0);
time=(land(end)-1)/100;
dist=vx0*time;
height2=max(height);
fprintf('Distance is %g m \n',dist);
fprintf('Max Height is %g m \n',height2);
fprintf('Time was %g sec \n ',time);
time2=t(land);
height3=height(land);
vxst=v*cosd(ang);
vyst=v*sind(ang);
heightst=vyst*t-.5*g*t.^2;
landst=find(heightst>=0);
timest=(landst(end)-1)/100;
distst=vxst*timest;
height2st=max(heightst);
time2st=t(landst);
height3st=heightst(landst);
plot(time2,height3)
hold on
plot(time2st,height3st)
xlabel('Time (Seconds)')
ylabel('Height (Meters)')
4 commentaires
darova
le 17 Avr 2020
I don't see any pause buttons. You don't use for loop also. How do you want to animate without loops?
Image Analyst
le 17 Avr 2020
darova: pause function, not pause button, but there is no call to pause() either. He should have a loop with a call to apuse inside the loop.
darova
le 17 Avr 2020
Yes i know. But the title says button
Walter Roberson
le 17 Avr 2020
You do need a loop for animation, unless you use comet() [which uses a timer.]
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Animation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!