📄 simpson.mht
字号:
From: <Saved by Windows Internet Explorer 7>
Subject:
Date: Tue, 12 May 2009 09:51: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/simpson.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>%
% Use Matlab's symbolic features to derive Simpson's 1/3 rule
%
% define matrix and vector...
%
% assume data pairs of: (0, y1), (h, y2), (2h, y3)
%
% fit to: f(x) =3D a_0 + a_1*x + a_2*x^2
%
A =3D sym('[1, 0, 0; 1, h, h^2; 1, 2*h, 4*h^2]')
b =3D sym('[y1; y2; y3]')
% solve system of equations
a =3D linsolve(A,b)
% form a_0 + a_1*x + a_2*x^2
f =3D =
symadd(symadd(sym(a,1,1),symmul(sym(a,2,1),'x')),symmul(sym(a,3,1),'x^2')=
)
% perform integration
i =3D int(f,0,'2*h')
% results
%
% A =3D [ 1, 0, 0]
% [ 1, h, h^2]
% [ 1, 2*h, 4*h^2]
%
% b =3D [ y1]
% [ y2]
% [ y3]
%
% a =3D [ y1]
% [-1/2*(3*y1+y3-4*y2)/h]
% [ 1/2*(y1+y3-2*y2)/h^2]
%
% f =3D y1-1/2*(3*y1+y3-4*y2)/h*x+1/2*(y1+y3-2*y2)/h^2*x^2
%
% i =3D 1/3*h*(y1+4*y2+y3) as we expect!
%
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -