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

조회 수: 2 (최근 30일)
Vuong Thanh
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
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

답변 (1개)

VBBV
VBBV 2022년 5월 8일
y=eval(ySol(t))% Use ySol(t) to evaluate
  댓글 수: 2
VBBV
VBBV 2022년 5월 8일
편집: VBBV 2022년 5월 8일
plot(subs(xSol,t,-5:5),subs(ySol,t,-5:5));
Then use subs to plot result
VBBV
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));

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

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by