⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simpdemo_out.mht

📁 it is a very essential matlab code.
💻 MHT
字号:
From: <Saved by Windows Internet Explorer 7>
Subject: 
Date: Tue, 12 May 2009 09:52:38 -0700
MIME-Version: 1.0
Content-Type: text/html;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.mece.ualberta.ca/Courses/mec390/390code/simpdemo.out
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 6.00.6000.16825" name=3DGENERATOR></HEAD>
<BODY><PRE>&gt;&gt; type simpdemo.m

% Simpson's rule integration demo

fprintf('\n Simpsons 1/3 rule integration demo\n');

n =3D 2;
olderror =3D 1;
fprintf('\n  n        integral       error      fract prev error    =
flops\n\n');
while n &lt; 32768
  flops(0);         % floating point count to zero
  t =3D clock;        % current time

  a =3D 0;
  b =3D pi;
  h =3D (b-a)/n;
  x =3D a:h:b;
  y =3D sin(x);
  simpint =3D simp0(y,h);

  error =3D 2.0 - simpint;
  ratio =3D error/olderror;
  olderror =3D error;
  fprintf('%6.0f %14.9f %14.5e %10.3f % =
14.0f\n',n,simpint,error,ratio,flops);

  n =3D n*2;
end;

fprintf('\nelapsed time: %4.2f\n\n',etime(clock,t));


&gt;&gt; simpdemo


 Simpsons 1/3 rule integration demo

  n        integral       error      fract prev error    flops

     2    2.094395102  -9.43951e-002     -0.094             17
     4    2.004559755  -4.55975e-003      0.048             23
     8    2.000269170  -2.69170e-004      0.059             35
    16    2.000016591  -1.65910e-005      0.062             59
    32    2.000001033  -1.03337e-006      0.062            107
    64    2.000000065  -6.45300e-008      0.062            203
   128    2.000000004  -4.03226e-009      0.062            395
   256    2.000000000  -2.52003e-010      0.062            779
   512    2.000000000  -1.57532e-011      0.063           1547
  1024    2.000000000  -9.80993e-013      0.062           3083
  2048    2.000000000  -5.68434e-014      0.058           6155
  4096    2.000000000  -4.44089e-015      0.078          12299
  8192    2.000000000   4.21885e-015     -0.950          24587
 16384    2.000000000  -1.11022e-014     -2.632          49163

elapsed time: 4.13

</PRE></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -