4阶龙格-库塔
4阶龙格-库塔网上搜的到吧希望您也能给我一份
4阶龙格-库塔算法解微分方程matlab的,希望你也能给我一份我会不胜感激,师兄!!我的邮箱yubingp@yahoo.com.cn
顶
我做过,不过用matlab 原帖由 yubingp 于 2006-10-26 03:28 发表4阶龙格-库塔算法解微分方程matlab的,希望你也能给我一份
我会不胜感激,师兄!!我的邮箱yubingp@yahoo.com.cn
matlab赏析区有程序,自己找一下吧 我也正需要,请给一份MATLAB的程序,谢谢
lzhh@cuit.edu.cn 回复:(shuijing)用matlab可以的话,我可以给你一个...
可以给我也发一个吗?
谢谢!
wangyinding@163.com 我能不能看看?zhuqiuling@163.com (*RUNGE-KUTTA (ORDER 4) ALGORITHM 5.2
*
* To approximate the solution of the initial value problem:
* Y' = F(T,Y), A <= T <= B, Y(A) = ALPHA,
* at n+1 equally spaced points in the interval .
*
* INPUT: endpoints a, b; initial condition ALPHA; integer n.
*
*OUTPUT: Approximation W to Y at the (n+1) values of T.
*)
TEMP=Input["This is the Runge-Kutta Order Four Method\n
Input the function F(T,Y) in terms of t and y\n
\n
For example: y-t^2+1\n"];
F :=Evaluate;
OK = 0;
While[OK == 0,
A=Input["Input the left endpoint\n"];
B=Input["Input the right endpoint\n"];
If[A >= B,
Input["Left endpoint must be less than right endpoint\n
\n
Press 1 to continue\n"],
OK = 1;
];
];
ALPHA=Input["Input thr initial condition\n"];
OK=0;
While[OK == 0,
n=Input["Input a positive integer for the number of\n
subintervals\n"];
If[n<=0,
Input["Number must be a positive integer\n
\n
Press 1 to continue\n"],
OK=1;
];
];
If[OK == 1,
FLAG = Input["Select output destination\n
1. Screen\n
2. Text file\n
Enter 1 or 2\n"];
If[FLAG == 2,
NAME = InputString["Input the file name\n
For example: output.dta\n"];
OUP = OpenWrite,
OUP = "stdout";
];
Write;
Write;
Write;
(* Step 1 *)
H=N[(B-A)/n];
T=A;
W=ALPHA;
Write];
(* Step 2 *)
For[i=1,
i<=n,
i++,
(* Step 3 - Use K1,K2,K3,K4, for K(1),K(2),K(3),K(4) resp. *)
K1=H*F;
K2=H*F;
K3=H*F;
K4=H*F;
(* Step 4 - Compute W(I) *)
W=W+(K1+2.0*(K2+K3)+K4)/6.0;
(* Comput T(I) *)
T=A+i*H;
(* Step 5 *)
Write];
];
(* Step 6 *)
If",
Print["Output file: ",NAME," created successfully\n"];
Close
];
];