getting y1(i)=traj​ectory(x1(​i),v0,thet​a) presents an error

조회 수: 3 (최근 30일)
Abdullah Ahmad
Abdullah Ahmad 2020년 11월 6일
x=0;
y=4;
v0=80;
theta=50:10:90;
g=9.8;
disp('part a')
% a) and b)
fprintf("Theta(d)\t height(m)\t Range(m)\n");
for t = 1:length(theta)
ph=get_maxheight(v0,theta(t));
R=get_Range(ph,theta(t));
fprintf("%.2f \t\t %.2f\t\t %.2f\n",theta(t),ph,R);
x1=x:1:R;
y1=zeros(length(x1));
for i=1:length(x1)
y1(i)=trajectory(x1(i),v0,theta(t));
end
plot(x1,y1)
title('Projectile path')
grid on
xlabel('x')
ylabel('y')
hold on
end
disp('part c')
% c)
x=0;
v0=80;
theta=45;
y=2:2:10;
fprintf("y(m)\t height(m)\t Range(m)\n");
for t = 1:length(y)
ph=get_maxheight(v0,theta);
R=get_Range(ph,theta);
fprintf("%.2f \t\t %.2f\t\t %.2f\n",y(t),ph,R);
end
%%%% Range Function %%%
function R=get_Range(mh,theta)
R=(mh*4)/tand(theta);
end
%%% Max Heigt Function %%%
function mh=get_maxheight(v0,theta)
mh=(v0*v0*sind(theta)*sind(theta))/(2*9.8);
end
%%% Theta Function %%%
function theta=get_theta()
theta=input('Enter angle of projection(theta): ');
end
%%% V0 Function %%%
function v0=get_v0()
v0=input('Enter initial velocity(v0): ');
end
%%% X Function %%%
function x=get_x()
x=input('Enter horizontal position(x): ');
end
%%% Y Function %%%%
function y=get_y()
y=input('Enter vertical position(x): ');
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by