Borrar filtros
Borrar filtros

i am suppossed to plot a trajectory motion with assigned colors for each graph, all I is matrix dimension must agree on line 22 & 21. and if it does plot the the graph does not go all the way to y=0 they just end halfway. here is my code

1 visualización (últimos 30 días)
%launching a projectile function [d,t,h] = fire_projectile(v,y0,theta) v=input('put the initial velocity:'); y0=input('put the launch height:');
% other inputs % g= accelaration due to gravity % theta= projectile launch angle % Xo = initial starting distance = 0
% outputs % d = maximum horizontal distance of the projectile % h = maximum height of projectile % t = time travelled by projectile
g = 9.81; theta=10:10:80; r=theta*(pi/180); for theta=10:10:80 d=((v*cos(r))/g).*((v*sin(r))+sqrt((v*sin(r)).^2+2*g*y0)); x=linspace(0,10,100); y=y0+(x.*tan(r))-((g*x.^2)/2*(v*cos(r).^2)); % Height of projectile at position plot(x,y) hold on end h=((v^2)*(sin(r)).^2)/(2*g); %maximum height of projectile t=d/(v*cos(r)); %time travelled title('Trajectory Motion','fontsize', 15) legend('theta=10[k]','theta=20[y]','theta=30[r]','theta=40[b]','theta=50[m]','theta=60[g]','theta=70[c]','theta=80[w]') xlabel('Distance travelled (m)') ylabel('Height of projectile (m)') fprintf('distance travelled: %g\r\n', d) fprintf('time travelled: %g\r\n', t) fprintf('maximum heigth: %g\r\n', h) end

Respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by