usage of ode45

조회 수: 1 (최근 30일)
Hicham
Hicham 2024년 4월 12일
댓글: Star Strider 2024년 4월 14일
i have 3 differential eqns that i would like to solve using ode45. M, l1, V are all varying w.r.t. time evrything else are just constants

답변 (1개)

Star Strider
Star Strider 2024년 4월 12일
imshow(imread('WhatsApp Image...16.45 PM.jpeg'))
syms M(t) I_1(t) I_2 V(t) t g mu A Y T
Eq1 = diff(M) == -g*V*A
Eq1(t) = 
Eq2 = diff(V) == I_1*g/(I_1+I_2) - 8*pi*mu*V/(g*A)
Eq2(t) = 
Eq3 = diff(I_1) == -V
Eq3(t) = 
[VF,Subs] = odeToVectorField(Eq1, Eq2, Eq3)
VF = 
Subs = 
fcn = matlabFunction(VF, 'Vars',{T,Y,g,I_2,mu,A})
fcn = function_handle with value:
@(T,Y,g,I_2,mu,A)[(g.*Y(3))./(I_2+Y(3))-(mu.*pi.*Y(1).*8.0)./(A.*g);-A.*g.*Y(1);-Y(1)]
g = rand
g = 0.3866
I2 = rand
I2 = 0.7057
mu = rand
mu = 0.0208
A = rand
A = 0.1406
[t,y] = ode45(@(t,y)fcn(t,y,g,I2,mu,A), [0,100], rand(3,1));
figure
plot(t, y)
grid
xlabel('Time')
ylabel('Amplitude')
legend(string(Subs), 'Location','best')
Make appropriate corrections to the symbolic variables (I am not certain that I transcribed them correctly), supply values for the constants parameters, and then use ode45 (or ode15s if the parameters vary significantly in magnitude) to solve it numerically.
.
  댓글 수: 2
Hicham
Hicham 2024년 4월 13일
what was the function matlabFunction that u used. and how can i program it without the usage of the first ode dm/dt
Star Strider
Star Strider 2024년 4월 14일
The matlabFunction function is part of the Symbolic Math Toolbox.
If you do not want to include the first differential equation, do not include it in the odeToVectorField arguments, using:
[VF,Subs] = odeToVectorField(Eq2, Eq3)
instead.
.

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

카테고리

Help CenterFile Exchange에서 Ordinary Differential Equations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by