Why is ySol(t) = Dsolve(ode,cond) wrong? What should it be instead?

2 views (last 30 days)
The equation of motion of the oblique throw in a gravity field with environmental resistance is expressed by the following expression:
m*a(vecto)=m*g(vecto)-h*v(vecto)
x0=y0=0; v0x=v0cos(alpha);v0y=v0sin(alpha).
the code i wrote:
m= input('Nhap vao khoi luong vat, m= 0.5');
h= input('Nhap vao he so luc can, h= 0.02');
v0= input('Nhap vao van toc ban dau, v0= 20');
alpha= input('Nhap vao alpha, alpha= pi/4');
g=input('Nhap vao trong truong,g=-9.81');
syms x(t) t
eqn=diff(x,t,2)+(h/m)*diff(x,t)==0;
Dx=diff(x,t);
cond= [x(0)==0,Dx(0)==v0*cos(alpha)];
xSol(t)=dsolve(eqn,cond)
x=eval(x)
syms y(t) t
eqn=diff(y,t,2)+(h/m)*diff(y,t)+g==0;
Dy=diff(y,t);
cond= [y(0)==0,Dy(0)==v0*sin(alpha)];
ySol(t)=dsolve(eqn,cond)
y=eval(y)
ezplot(x, y) % ve quy đao chuyen đong cua vat
end
Error using mupadengine/feval_internal
No differential equations found. Specify differential equations by using symbolic functions.
Error in dsolve>mupadDsolve (line 334)
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 203)
sol = mupadDsolve(args, options);
pls, thank very so much

Answers (1)

VBBV
VBBV on 8 May 2022
y=eval(ySol(t))% Use ySol(t) to evaluate
  2 Comments
VBBV
VBBV on 8 May 2022
Edited: VBBV on 8 May 2022
plot(subs(xSol,t,-5:5),subs(ySol,t,-5:5));
Then use subs to plot result
VBBV
VBBV on 8 May 2022
h = 0.02;
v0 = 20;
m = 0.5;
alpha = pi/4;
g = -9.81;
syms x(t) t
eqn=diff(x,t,2)+(h/m)*diff(x,t)==0;
Dx=diff(x,t);
cond= [x(0)==0,Dx(0)==v0*cos(alpha)];
xSol(t)=dsolve(eqn,cond)
xSol(t) = 
x=eval(xSol(t))
x = 
syms y(t) t
eqn=diff(y,t,2)+(h/m)*diff(y,t)+g==0;
Dy=diff(y,t);
cond= [y(0)==0,Dy(0)==v0*sin(alpha)];
ySol(t)=dsolve(eqn,cond)
ySol(t) = 
y=eval(ySol(t))
y = 
plot(subs(x,t,-5:0.1:5),subs(y,t,-5:0.1:5));

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!