📄 simp1.mht
字号:
From: <Saved by Windows Internet Explorer 7>
Subject:
Date: Tue, 12 May 2009 09:52:06 -0700
MIME-Version: 1.0
Content-Type: text/html;
charset="Windows-1252"
Content-Transfer-Encoding: 7bit
Content-Location: http://www.mece.ualberta.ca/Courses/mec390/390code/simp1.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=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 6.00.6000.16825" name=GENERATOR></HEAD>
<BODY><PRE>function q = simp1(y,h);
% function simp1(y,h); Simpson's 1/3 quadrature rule
%
% input: y - function vector to be integrated
% h - interval width
% output: integral in the given region
n = length(y) - 1; % number of regions
if (n/2) ~= floor(n/2) % check to see if even
fprintf('\nError: must have odd number of data points\n');
break;
end
v = 2 * ones(n+1,1); % these commands form : 2 4 2 4 ... 4 2 4 2
v2 = 2 * ones(n/2,1);
v(2:2:n) = v(2:2:n) + v2;
v(1) = 1; % this correct the end points
v(n+1) = 1;
q = y * v; % row vector * column vector = sum(y_i * v_i)
q = q * h/3; </PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -