Solving Coupled Differential Equations
Info
This question is closed. Reopen it to edit or answer.
Show older comments
So, I have two programs, a runner and a function. I am fairly new to MATLAB so any help would be nice. I am not getting calculated values for N(:, 2) and N(:, 3).
Runner:
tspan = [0 10];
global B11;
B11 = 10^-6;
N0 = [1; 1; 1];
global B12;
B12 = 2.8*10^2;
global B22;
B22 = 10^-6;
global I;
I = 10^9;
global v0;
v0 = 1.4*10^-20;
[t,N] = ode45(@bimodaltest, tspan, N0);
Nt = N(:, 1) + N(:, 2);
Vt = N(:, 1).* v0;
plot(N(:, 3), N(:,1), N(:,3), N(:,2));
legend('N1','N2');
.
Function:
function dNdt = bimodaltest(t, N);
global B11;
global B12;
global B22;
global r;
global k;
global v0;
if N(1)>0
r= N(3, :)/((N(2, :))^2 * v0);
else
r = 2;
dNdt = [1; 1; 1];
k = 0;
end
global I;
dNdt(1) = (-.5.*B11)*(r./(r-1)).*(N(1)^2) - B12*N(2).*N(1) + I;
dNdt(2) = (- 0.5*B22).*(N(2)^2) + (0.5.*B11)*(N(1).^2).*(1./(r-1))+I;
dNdt(3) = (.5*B11*(r/(r-1))*(N(1)^2))*v0 + B12*N(1)*N(2)*v0;
dNdt = dNdt';
If you guys could tell me ASAP what's wrong with my code, I'd really appreciate it.
Answers (0)
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!