I tried to solve projectile motion problem (velocity about physic) with matlab . I have some troubles ... Please help me immediately

g=9.80665;
T=37;
V0=100;
Vx=(V0*cos(T))
Vy=abs(V0*sin(T))
tu=(Vy/g)
t=(1:tu) --------------- When I changed like that t=(1:0.1:tu) / float
Programme gives error like that:
Array indices must be positive integers or logical values.
Error in V_T (line 9)
y(t)=(Vy-g*(t))
y(t)=(Vy-g*(t)
x(t)=Vx
y2(t)=(-Vy-g*(t))
A=[y(t),y2(t)]
B=[x(t),x(t)]
V=A.^2+B.^2

1 Comment

y=Vy-g*t; %should work
If T is in degrees (which it appears to be), then you should use
Vx=V0*cosd(T);
Vy=V0*sind(T);
Also, x(t)=... and y2(t)=... will produce errors, and you shoudl use x=... and y2=...
Check the right hand side of your equations. Are they correct?

Sign in to comment.

 Accepted Answer

Help immediately? Lucky to get a response.
g=9.80665;
T=37;
V0=100;
Vx=V0*cosd(T);
Vy=V0*sind(T);
tu=Vy/g;
t=0:.001:tu;
Vy=Vy-g*t;
Vx=Vx*ones(size(t));
V=hypot(Vx,Vy);
plot(t,Vx,t,Vy,t,V);

More Answers (1)

I agree with the comment of @David Hill.
I inteneded to make an answer not a comment.
y=Vy-g*t; %should work
If T is in degrees (which it appears to be), then you should use
Vx=V0*cosd(T);
Vy=V0*sind(T);
Also, x(t)=... and y2(t)=... will produce errors, and you shoudl use x=... and y2=...
Check the right hand side of your equations. Are they correct?

Categories

Find more on Mathematics in Help Center and File Exchange

Products

Release

R2021b

Community Treasure Hunt

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

Start Hunting!