我正在尝试使用 ode 求解器求解 3 个不同的方程(洛伦兹方程):Matlab 中的 ode23s。这是3个洛伦兹方程:
dc/dt= alpha*I*(1-c) + c*(- k_f - k_d - k_n * s - k_p*(1-q))
ds/dt = lambda_b * c* P_C *(1-s)- lambda_r *(1-q)*s
dq/dt = (1-q)* k_p * c *(P_C / P_Q)- gamma * q
我使用了 ode 求解器并创建了两个 M 文件 ode.m 和 lorenz.m
=> 这是我的两个 Matlab M 文件。这是我的第一个 M 文件:ode.m,我运行它来绘制图形。
format bank
close all;
clear all;
clc;
%time interval
ti=0;
tf=140;
tspan=[ti tf];
x0=[0.25 0.02 0.98]; %initial vectors
%time interval of [0 2] with initial condition vector [0.25 0.02 0.02] at time 0.
options= odeset('RelTol',1e-4, 'AbsTol',[1e-4 1e-4 1e-4]);
[t,x]= ode23s('lorenz',tspan,x0,options);
%Plotting the graphs:
figure
subplot(3,1,1), plot(t,x(:,1),'r'),grid on;
title('Lorenz Equations'),ylabel('c');
subplot(3,1,2), plot(t,x(:,2),'b'),grid on;
ylabel('s');
subplot(3,1,3), plot(t,x(:,3),'g'),grid on;
ylabel('q');xlabel('t')
这是我的第二个 M 文件,即 lorenz.m
% Creating the MATLAB M-file containing the Lorenz equations.
function xprime= lorenz(t,x)
%values of parameters
I=1200;
k_f= 6.7*10.^7;
k_d= 6.03*10.^8;
k_n=2.92*10.^9;
k_p=4.94*10.^9;
lambda_b= 0.0087;
lambda_r =835;
gamma =2.74;
alpha =1.14437*10.^-3;
P_C= 3 * 10.^(11);
P_Q= 2.87 * 10.^(10);
% initial conditions
c=x(1);
s=x(2);
q=x(3);
%Non-linear differential equations.
% dc/dt= alpha*I*(1-c) + c*(- k_f - k_d - k_n * s - k_p*(1-q))
% ds/dt = lambda_b * c* P_C *(1-s)- lambda_r *(1-q)*s
% dq/dt = (1-q)* k_p * c *(P_C / P_Q)- gamma * q
xprime=[ alpha*I*(1-c) + c*(- k_f - k_d - k_n * s - k_p*(1-q)); lambda_b *(1-s)* c* P_C - lambda_r *(1-q)*s; (1-q)*k_p * c *(P_C / P_Q)- gamma * q];
请帮帮我,两个 M 文件代码都在工作,但我想在 lorenz.m 文件中使用函数句柄 (@lorenz),因为 Lorenz 对这个问题的描述不是很好。而且,当我运行 ode.m 文件时,plot 的值非常小,但是当我运行 lorenz.m 文件时,c、s、q 的值非常大。我想在某个地方获取 s 和 q 的值在 0 到 1 之间。并且 c 的值应该是非常大的数字,大约 3.5 X10^11。我不知道这是怎么回事?