📄 irrarea.mht
字号:
From: <Saved by Windows Internet Explorer 7>
Subject:
Date: Tue, 12 May 2009 09:58:48 -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/irrarea.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 [a, xbar, ybar] = irrarea(D)
% Computes area of irregular closed contour given by coordinates
% stored in array D. The first column of D contains the x-coordinate
% and the second column contains the y-coordinates.
%
% Note: the first point will automatically be duplicated as the last
%
% USAGE: area = irrarea(D)
x = D(:,1);
y = D(:,2);
nm = length(x);
n = nm+1;
x(n) = x(1);
y(n) = y(1);
sum = 0;
sumx = 0;
sumy = 0;
for i=1:nm
dA = (x(i)*y(i+1) - x(i+1)*y(i))/2;
sum = sum + dA;
sumy = sumy + (y(i)+y(i+1)) * dA / 3;
sumx = sumx + (x(i)+x(i+1)) * dA / 3;
end
a = sum;
xbar = sumx / a;
ybar = sumy / a;
plot(x,y,xbar,ybar,'r+')
</PRE></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -