clc;
% Data Taken from given projectile phots and vedios
%Flight time(seconds) is calculated using vedio real time
% Angle(degree) is measured using photo when projectile lanching
% height(m) is calculated as disatnce between ground and projectile
% Flight time = Tf
% Angle = theta
Tf=20;
theta=60;
height=5000;
g=9.81;
velocity=(g*Tf)/(2*sind(theta))
velocity = 113.2761
%1feet=0.3048m
figure;
hold on;
e=1;
A=[0.3048];
B=[1000:100:10000];
C=A*B;
for height= [5000:100:30000]
for range=C
[maxHeight(e),horDist(e)]=projMotion(velocity,height,range);
e=e+1;
end
end
Angle = 3×1
-86.5115 -4.8298 4.8051
Vyi = 3×1
-113.0662 -9.5373 9.4888
Vxi = 3×1
6.8927 112.8739 112.8780
maxHeight = 3×1
1.0e+03 * 5.6516 5.0046 5.0046
tmax = 1×3
0 0 2.7003
horDist = 304.8000
d = 3×1
5000 5000 5000
Hittingvelocity = 3×3
113.2761 113.2761 139.7259 113.2761 113.2761 118.4840 113.2761 113.2761 114.1511
Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
xlabel('Horizontal Distance (m)');
ylabel('Vertical Distance (m)');
title('Projectile Motion');
function [maxHeight,horDist] = projMotion(velocity,height,range)
% finding angle
g=9.81;
a=1;
b=height/range;
c=0;
d=(-g*range)/(2*velocity.^2);
p=[a b c d];
r=roots(p);
Angle=atand(r)
for angle=[Angle]
Vyi=velocity*sind(angle)
Vxi=velocity*cosd(angle)
maxHeight=height+Vyi.^2/g-0.5*(Vyi.^2/g)
tmax=range/Vxi
for t=[0:0.001:tmax]
horDist=tmax*Vxi
d=height+Vyi*t-.5*g*t.^2
plot(Vxi*t,d)
hold on
Hittingvelocity=sqrt((velocity*sind(angle)-g*tmax).^2+(velocity*cosd(angle)).^2)
end
end
end

回答 (2 件)

Hussain Alsalman
Hussain Alsalman 2022 年 11 月 13 日

0 投票

I need to find out projectile angle when velocity,intial height,range given.
please help me to sort out this error
Walter Roberson
Walter Roberson 2022 年 11 月 13 日

0 投票

p=[a b c d];
vector length 4
r=roots(p);
roots() returns a column vector of length one less than the length of the vector, so 3x1 in this case
Angle=atand(r)
atand of a column vector is a column vector
for angle=[Angle]
"for" loops over the *columns" of the right hand side. It is not going to iterate the three roots one at a time: it is going to iterate once with angle set to the three roots as a vector.

2 件のコメント

Hussain Alsalman
Hussain Alsalman 2022 年 11 月 13 日
do i need to angle output as a column vector
Walter Roberson
Walter Roberson 2022 年 11 月 13 日

You already have it as a column vector, and that is what is leading to problems. Your for angle loop needs the right hand side to be a row vector.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

製品

質問済み:

2022 年 11 月 13 日

コメント済み:

2022 年 11 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by