필터 지우기
필터 지우기

Please amend my code :(

조회 수: 2 (최근 30일)
지원 안
지원 안 2021년 5월 23일
답변: Girijashankar Sahoo 2021년 5월 23일
I want V when x=5000 but something wrong...
please amend my code
clear all
close all
grav=9.81;
theta=pi/4;
v=20;
x=0; vx=cos(theta).*v;
y=0; vy=sin(theta).*v;
dt=0.05;
for n=1:100
x=x+vx*dt;
vx=vx+vx.*dt;
y=y+vy*dt
vy=vy-grav*dt;
if(y<0); break; end
n=1:10000
if(x==5000);break; end
else(x<5000);
v=v+1;
end
v

답변 (1개)

Girijashankar Sahoo
Girijashankar Sahoo 2021년 5월 23일
%% if statement end after else, #look the code again
grav=9.81;
theta=pi/4;
v=20;
x=0; vx=cos(theta).*v;
y=0; vy=sin(theta).*v;
dt=0.05;
for n=1:100
x=x+vx*dt;
vx=vx+vx.*dt;
y=y+vy*dt
vy=vy-grav*dt;
if(y<0); break; end
n=1:10000
if(x==5000);break;
else(x<5000);
v=v+1;
end
end
v

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by