【问题标题】:Projectile motion [closed]弹丸运动[关闭]
【发布时间】:2019-04-20 19:43:22
【问题描述】:

我应该编写一个提供多行抛射运动的脚本,但我的代码似乎无法满足我的需求。

disp('This program will calculate the trajectory of a ball thrown at an initial speed vo \n')
v0 = input('Please enter the initial speed');
x0 = 0;
y0 = 0;
g = 9.81;%m/s^2
T = 5 : 5 : 85;
vx = v0*cosd(T);
vy = v0*sind(T);
t = (2*v0.*sind(T))/g;
y = y0 + (vy.*t) - ((g.*(t.^2))/2);
x = x0 + vx.*t;
plot(x,y)

图表应该是这样的:

【问题讨论】:

    标签: matlab graph matlab-figure projectile


    【解决方案1】:

    在您的代码中,T 表示初始度数。您想计算不同初始度数的xy (5:5:85)。对T 使用for 循环,并为不同的t 绘制xy

    disp('This program will calculate the trajectory of a ball thrown at an initial speed vo \n')
    v0 = input('Please enter the initial speed');
    x0 = 0;
    y0 = 0;
    g = 9.81;%m/s^2
    for T = 5 : 5 : 85
        vx = v0*cosd(T);
        vy = v0*sind(T);
        t = linspace(0,(2*v0.*sind(T))/g,100);
        y = y0 + (vy.*t) - ((g.*(t.^2))/2);
        x = x0 + vx.*t;
        plot(x,y)
        hold on
        xlim([-inf inf])
        ylim([-inf inf])
    end
    

    输出:

    This program will calculate the trajectory of a ball thrown at an initial speed vo \n
    Please enter the initial speed10
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多