trajectory.m

来自「This function is used to evaluate the ma」· M 代码 · 共 31 行

M
31
字号
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 + =
减小字号Ctrl + -
显示快捷键?