?? trajectory.m
字號:
function [hmax,dmax] = trajectory(v0,theta)% This function is used to evaluate the max height and the max% distance of a projectile and plot the trajectory.% Inputs% v0 : The initial velocity in m/s% theta: The angle at which the projectile is fired in degrees% Outputs% hmax : The maximum hieght in m% dmax : The maximum distance in mg = 9.81;v0x = v0*cos(theta*pi/180);v0y = v0*sin(theta*pi/180);thmax = v0y/g;hmax = v0y^2/(2*g);ttol = 2*thmax;dmax = v0x*ttol;% Create the plot of the trajectorytplot = linspace(0,ttol,200);x = v0x*tplot;y = v0y*tplot - 0.5*g*tplot.^2; %.^2 for element multiplicationplot(x,y)xlabel('Distance(m)')ylabel('Height(m)')title('Projectile Trajectory')%
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -