📄 simpdemo.mht
字号:
From: <Saved by Windows Internet Explorer 7>
Subject:
Date: Tue, 12 May 2009 09:52:26 -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.m
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>% 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 < 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; % exact result of integral is 2.0
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));
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -