ode求解常微分方程如何获得某个点的数值解

조회 수: 3 (최근 30일)
ma xueyi
ma xueyi 2022년 5월 7일
댓글: Dyuman Joshi 2024년 1월 24일
function dx = odefun(t,x)
ki1= 13.0;
ki2= 0.0;
kp11= 3.70e+04;
kp12= 673;
kp21= 1.36e+03;
kp22= 46;
ktal= 2.5;
kd= 1.0e-04;
hp1 = 101500000;
hp2 = 83000000;
dx = zeros(13,1);
dx(1) =ktal.*(x(5)+x(6)).*x(2)-ki1.*x(1).*x(3)-ki2.*x(1).*x(4);
dx(2) =ktal.*x(2).*(x(7)+x(8));
dx(3) =(ki1.*x(1)+kp11.*x(5)+kp21.*x(6)).*x(3);
dx(4) =(ki2.*x(1)+kp12.*x(5)+kp22.*x(6)).*x(4);
dx(5) =ki1.*x(1).*x(3)+kp21.*x(6).*x(3)-kp12.*x(5).*x(4)-(ktal.*x(2)+kd).*x(5);
dx(6) =ki2.*x(1).*x(4)+kp12.*x(5).*x(4)-kp21.*x(6).*x(3)-(ktal.*x(2)+kd).*x(6);
dx(7) =ki1.*x(1).*x(3)+kp11.*x(5).*x(3)+kp21.*(x(8)+x(6)).*x(3)-kp12.*x(7).*x(4)-(ktal.*x(2)+kd).*x(7);
dx(8) =ki2.*x(1).*x(4)+kp22.*x(6).*x(4)+kp12.*(x(7)+x(5)).*x(4)-kp21.*x(8).*x(3)-(ktal.*x(2)+kd).*x(8);
dx(9) =ki1.*x(1).*x(3)+kp11.*(2.*x(7)+x(5)).*x(3)+kp21.*(x(10)+2.*x(8)+x(6)).*x(3)-kp12.*x(9).*x(4)-(ktal.*x(2)+kd).*x(9);
dx(10) =ki2.*x(1).*x(4)+kp22.*(2.*x(8)+x(6)).*x(4)+kp12.*(x(9)+2.*x(7)+x(5)).*x(4)-kp21.*x(10).*x(3)-(ktal.*x(2)+kd).*x(10);
dx(11) =(ktal.*x(2)+kd).*(x(5)+x(6));
dx(12) =(ktal.*x(2)+kd).*(x(7)+x(8));
dx(13) =(ktal.*x(2)+kd).*(x(9)+x(10));
end
clear
clc
tspan=[0,1200];
y0=[2e-5,0.04,0.1524,1.0194,0,0,0,0,0,0,0,0,0];
[T,X] = ode45(@odefun,tspan,y0);
plot(T,X(:,1),'-',T,X(:,2),'-.',T,X(:,3),'.')
legend('x','y','z')
%mex(filename.c,'-compatibleArrayDims')
我的代码如上,但在点击运行后,约10分钟后报错
今天重新跑,运行二十分钟后一直没反应
我的疑问:
1.我的文件是否真的这么大,需要占用这么大数据量
2.网上查到的用例都是绘图,请问十三个未知数如何绘图
3.实际上我不关心过程,只想知道t=1200时,各自变量的数值
  댓글 수: 1
Dyuman Joshi
Dyuman Joshi 2024년 1월 24일
I am not sure what you are trying to solve.
Could you please share which equation (or system of equations) you are trying to solve?
I don't see a relation between the error showed and the code posted.

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

답변 (1개)

Varun
Varun 2024년 1월 23일
Hey! Here are some things you can try out:
  1. Go to MATLAB -> Preferences -> Workspace -> MATLAB array size limit and set it to 100%.This will help you utilize all the RAM available on your device.
  2. Refer to the following documentation: https://www.mathworks.com/help/matlab/large-files-and-big-data.html. This will guide to a bunch of alternatives supported by MATLAB that you can employ as per your usecase.
Hope this helps!

카테고리

Help CenterFile Exchange에서 编程에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!