usage of ode45

8 Ansichten (letzte 30 Tage)
Hicham
Hicham am 12 Apr. 2024
Kommentiert: Star Strider am 14 Apr. 2024
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

Antworten (1)

Star Strider
Star Strider am 12 Apr. 2024
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 Kommentare
Hicham
Hicham am 13 Apr. 2024
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 am 14 Apr. 2024
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.
.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by