ODE solution for a magnetic flux equation
Show older comments
i am new to matlab so i just wanted to ask how i could go about solving a ode that looks like this:
i tried using ODE45 and the code can be found below but for some reason it has been giving me nonstop errors and refuses to solve the equation. Here is the function i wrote. y argument is a time dependant variable that has a behaviour much like an exponential function
function dphidt = first_order(~,phi,y)
t = 0:0.1:10;
k1 = 3.978873577297383e+10;
k2 = 200000;
k3 = 4.299999999999999e+03;
a = 5 / 100;
b = (804 * k1) /10000;
c = (804 * k2) /10000;
dphidt = zeros(size(t));
for i = 1:length (dphidt)
dphidt(i) = a - b*y(i)*phi - ( (c*phi) / 1-(k3*phi) ) ;
end
dphidt = dphidt';
end
and heres the simulation code:
t = 0:0.1:10;
phi0 = 0*ones(1, 101);
y = exp(t);
ode_func = @(t, phi) first_order(t, phi, y);
z = ode45( ode_func,t, phi0);
time = z.x;
Y = z.y;
plot(time,Y);
xlabel('Time');
ylabel('y');
title('Simulation Results');
could someone guide me in writing this equation?
Accepted Answer
More Answers (0)
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

