how to fix this error
Mostra commenti meno recenti
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))
%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
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
Risposte (2)
Hussain Alsalman
il 13 Nov 2022
0 voti
Walter Roberson
il 13 Nov 2022
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 Commenti
Hussain Alsalman
il 13 Nov 2022
Walter Roberson
il 13 Nov 2022
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.
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
