声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

123
返回列表 发新帖
楼主: godgeninus

[分形与混沌] 用4阶龙格-库塔法解微分方程 各位高手 帮帮小弟

 关闭 [复制链接]
发表于 2006-9-20 20:31 | 显示全部楼层
我也正在用Matlab做,希望也能得到一份,另外是不是还能用Euler方法,有这方面的材料吗?
回复 支持 反对
分享到:

使用道具 举报

发表于 2006-10-12 22:01 | 显示全部楼层

4阶龙格-库塔

4阶龙格-库塔网上搜的到吧
发表于 2006-10-26 03:28 | 显示全部楼层

希望您也能给我一份

4阶龙格-库塔算法解微分方程matlab的,希望你也能给我一份
我会不胜感激,师兄!!我的邮箱yubingp@yahoo.com.cn
发表于 2006-10-30 09:34 | 显示全部楼层

我做过,不过用matlab
发表于 2006-11-7 00:14 | 显示全部楼层
原帖由 yubingp 于 2006-10-26 03:28 发表
4阶龙格-库塔算法解微分方程matlab的,希望你也能给我一份
我会不胜感激,师兄!!我的邮箱yubingp@yahoo.com.cn


matlab赏析区有程序,自己找一下吧
发表于 2006-12-11 12:40 | 显示全部楼层
我也正需要,请给一份MATLAB的程序,谢谢

lzhh@cuit.edu.cn
发表于 2006-12-17 15:28 | 显示全部楼层
回复:(shuijing)用matlab可以的话,我可以给你一个...
可以给我也发一个吗?
谢谢!
wangyinding@163.com
发表于 2006-12-19 16:10 | 显示全部楼层
我能不能看看?zhuqiuling@163.com
发表于 2007-3-7 20:29 | 显示全部楼层
  1. (*  RUNGE-KUTTA (ORDER 4) ALGORITHM 5.2
  2. *
  3. *   To approximate the solution of the initial value problem:
  4. *    Y' = F(T,Y), A <= T <= B, Y(A) = ALPHA,
  5. *    at n+1 equally spaced points in the interval [A,B].
  6. *
  7. *   INPUT: endpoints a, b; initial condition ALPHA; integer n.
  8. *
  9. *  OUTPUT: Approximation W to Y at the (n+1) values of T.
  10. *)
  11. TEMP=Input["This is the Runge-Kutta Order Four Method\n
  12. Input the function F(T,Y) in terms of t and y\n
  13. \n
  14. For example: y-t^2+1\n"];
  15. F[t_,y_] :=Evaluate[TEMP];
  16. OK = 0;
  17. While[OK == 0,
  18.    A=Input["Input the left endpoint\n"];
  19.    B=Input["Input the right endpoint\n"];
  20.    If[A >= B,
  21.       Input["Left endpoint must be less than right endpoint\n
  22.       \n
  23.       Press 1 [enter] to continue\n"],
  24.       OK = 1;
  25.    ];
  26. ];
  27. ALPHA=Input["Input thr initial condition\n"];
  28. OK=0;
  29. While[OK == 0,
  30.    n=Input["Input a positive integer for the number of\n
  31.    subintervals\n"];
  32.    If[n<=0,
  33.       Input["Number must be a positive integer\n
  34.         \n
  35.       Press 1 [enter] to continue\n"],
  36.       OK=1;
  37.    ];
  38. ];
  39. If[OK == 1,
  40.    FLAG = Input["Select output destination\n
  41.                  1. Screen\n
  42.                  2. Text file\n
  43.                  Enter 1 or 2\n"];
  44.    If[FLAG == 2,
  45.       NAME = InputString["Input the file name\n
  46.                           For example:   output.dta\n"];
  47.       OUP = OpenWrite[NAME,FormatType->OutputForm],
  48.       OUP = "stdout";
  49.    ];
  50.    Write[OUP,"Runge-Kutta Fourth Order Method\n"];
  51.    Write[OUP,"t          w  \n"];
  52.    Write[OUP,"\n"];
  53.    (* Step 1 *)
  54.    H=N[(B-A)/n];
  55.    T=A;
  56.    W=ALPHA;
  57.    Write[OUP,T,"        \n",N[W,9]];
  58.    (* Step 2 *)
  59.    For[i=1,
  60.       i<=n,
  61.       i++,
  62.       (* Step 3 - Use K1,K2,K3,K4, for K(1),K(2),K(3),K(4) resp. *)
  63.       K1=H*F[T,W];
  64.       K2=H*F[T+H/2.0,W+K1/2.0];
  65.       K3=H*F[T+H/2.0,W+K2/2.0];
  66.       K4=H*F[T+H,W+K3];
  67.       (* Step 4 - Compute W(I) *)
  68.       W=W+(K1+2.0*(K2+K3)+K4)/6.0;
  69.       (* Comput T(I) *)
  70.       T=A+i*H;
  71.       (* Step 5 *)
  72.       Write[OUP,T,"        \n",N[W,9]];
  73.    ];
  74.    (* Step 6 *)
  75.    If[OUP == "OutputStream[",NAME," 3]",
  76.       Print["Output file: ",NAME," created successfully\n"];
  77.       Close[OUP]
  78.    ];
  79. ];
复制代码
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-21 17:42 , Processed in 0.075911 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表