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

조회 수: 2(최근 30일)
Vuong Thanh 2022년 5월 8일
댓글: VBBV 2022년 5월 8일
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
No differential equations found. Specify differential equations by using symbolic functions.
T = feval_internal(symengine,'symobj::dsolve',sys,x,options);
Error in dsolve (line 203)
pls, thank very so much

댓글을 달려면 로그인하십시오.

### 답변(1개)

VBBV 2022년 5월 8일
y=eval(ySol(t))% Use ySol(t) to evaluate
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
VBBV 2022년 5월 8일
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));

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by