ODE with goniometric function
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi, how can I solve and plot this ODE: 1*y''+23.25*(2.5*sin(x+1.5))*y'=0
there is my code:
eqn = '1*D2y+23.25*(2.5*sin(x+1.5))*D1y = 0';
inits = 'y(0)=0.7, Dy(0)=6.2';
y=dsolve(eqn,inits,'x')
ezplot(y, [-1 10])
Thank you so much
댓글 수: 0
답변 (1개)
Star Strider
2018년 4월 10일
This works in R2018a, although it gives a ‘Warning’ about array inputs:
syms x y(x)
D1y = diff(y);
D2y = diff(D1y);
eqn = D2y+23.25*(2.5*sin(x+1.5))*D1y == 0;
inits = [y(0)==0.7, D1y(0)==6.2];
y=dsolve(eqn,inits)
Y = matlabFunction(y)
ezplot(Y, [-1 10])
This assumes that ‘y’ is a function of ‘x’. If both ‘x’ and ‘y’ are functions of another variable, we need to know.
댓글 수: 2
Star Strider
2018년 4월 11일
In R2018a the matlabFunction call produces:
Y =
function_handle with value:
@(x)exp(cos(3.0./2.0).*(-4.65e2./8.0)).*integral(@(y)exp(cos(y+3.0./2.0).*(4.65e2./8.0)),0.0,x).*(3.1e1./5.0)+7.0./1.0e1
or, more conveniently:
Y = @(x) exp(cos(3.0./2.0).*(-4.65e2./8.0)).*integral(@(y)exp(cos(y+3.0./2.0).*(4.65e2./8.0)),0.0,x).*(3.1e1./5.0)+7.0./1.0e1;
however only this construction appears to work:
Y = @(x) exp(cos(3.0./2.0).*(-4.65e2./8.0)).*integral(@(y)exp(cos(y+3.0./2.0).*(4.65e2./8.0)),0.0,x,'ArrayValued',1).*(3.1e1./5.0)+7.0./1.0e1;
X = linspace(-1, 10);
Yv = arrayfun(Y, X);
figure
plot(X, Yv)
grid
참고 항목
카테고리
Help Center 및 File Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!