I have the equation of this form below to be solved and I have written the attached code.
syms x(t) A(t) B(t) C(t) D y(t) t Y
x(t) = 20e-3:100e-3;
A(t) = 1./x(t);
B(t) = diff(x(t),t);
C(t) = diff(x(t),t,t);
D = 50;
D1y(t) = diff(y(t),t);
D2y(t) = diff(y(t),t,t);
D3y(t) = diff(y(t),t,t,t);
Eqn3 = D3y(t) + A(t)*D2y(t) + B(t)*D1y(t) + C(t)*y(t) + D == 0;
[VF3,Subs3] = odeToVectorField(Eqn3);
IC = [0;0;15e3]; % initial conditions
R = matlabFunction(VF3, 'Vars',{t,Y});
[T,I] = ode45(R,time,IC);
plot(T,I),grid
Just to be sure the code I have written is doing what I think, I would appreciate if someone could go through it.

댓글 수: 3

I have no idea what you want to solve for.
This may get you closer:
syms x(t) A(t) B(t) C(t) D y(t) t Y
% x(t) = 20e-3:100e-3;
A(t) = 1./x(t);
B(t) = diff(x(t),t);
C(t) = diff(x(t),t,t);
D = 50;
D1y(t) = diff(y(t),t);
D2y(t) = diff(y(t),t,t);
D3y(t) = diff(y(t),t,t,t);
Eqn3 = D3y(t) + A(t)*D2y(t) + B(t)*D1y(t) + C(t)*y(t) + D == 0;
[VF3,Subs3] = odeToVectorField(B,C,Eqn3);
IC = [0;0;0;0;15e3]; % initial conditions
R = matlabFunction(VF3, 'Vars',{t,Y});
time = [20 100]*1E-3;
[T,I] = ode45(R,time,IC);
figure
semilogy(T,I)
grid
legend(string(Subs3))
.
Hi Shozeal,
syms x(t) A(t) B(t) C(t) D y(t) t Y
x(t) = 20e-3:100e-3
A(t) = 1./x(t)
B(t) = diff(x(t),t)
C(t) = diff(x(t),t,t)
x(t) = 1/50
A(t) = 50
B(t) = 0
C(t) = 0
This does not appear to be what you want for x(t), As opposed to something like
x(t) = 1/(1+t^2)
A(t) = 1./x(t)
B(t) = diff(x(t),t)
C(t) = diff(x(t),t,t)
x(t) = 1/(t^2 + 1)
A(t) = t^2 + 1
B(t) = -(2*t)/(t^2 + 1)^2
C(t) = (8*t^2)/(t^2 + 1)^3 - 2/(t^2 + 1)^2
Shozeal
Shozeal 2021년 1월 14일
Thanks, Strider and David.
@Strider I am guessing you have included the initial condition for B(t) and C(t) in $IC = [0;0;0;0;15e3]$; % initial conditions.
I also noticed that you commented out x(t)=20e-3:100e-3, what if I knew the range of x(t) beforehand?
"I have no idea what you want to solve for." I was hoping to get the solution for y(t).
@David Well, that is the problem I have at hand, as stated above. Thank you for the suggestion.

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

 채택된 답변

Star Strider
Star Strider 2021년 1월 14일

0 개 추천

The Answers Comment and Answer windows are malfunctioning. I am having serious problems with the lack of formatting and other options here, so I may not be able to provide an appropriate link.
Neverhteless, the correct way to code a time-varying term in your ODE function is described in ODE with Time-Dependent Terms I have no idea how to use that approach in your system, because I have no idea what you want to do.
I can possibly help you with that if I understand what you want, and I may be able to post the results once Answers works correctly again.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2021년 1월 13일

답변:

2021년 1월 14일

Community Treasure Hunt

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

Start Hunting!

Translated by