HW 7 Ben - HW 7 25.1) By changing line 194 to z = (x +...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
HW 7 25.1) By changing line 194 to z = (x + y)./(x.^2 + y.^2) and commenting out lines 195 and 196 in mywasher, the following 3D plot is obtained: Now, in mywedge, once we change line 40 to z = sin(x) + sqrt(y) and comment out line 41, this is the 3D plot that we get:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
25.2) The following is the code for mycenters: function I = mycenters(f,V,T) % Integrates a function based on a triangulation, using three corners % Inputs: f -- the function to integrate, as an inline % V -- the vertices. Each row has the x and y coordinates of a vertex % T -- the triangulation. Each row gives the indices of three corners % Output: the approximate integral x = V(:,1); % extract x and y coordinates of all nodes y = V(:,2); I=0; p = size(T,1); for i = 1:p x1 = x(T(i,1)); % find coordinates and area x2 = x(T(i,2)); x3 = x(T(i,3)); y1 = y(T(i,1)); y2 = y(T(i,2)); y3 = y(T(i,3)); A = .5*abs(det([x1, x2, x3; y1, y2, y3; 1, 1, 1])); xbar = (x1 + x2 + x3)/3; ybar = (y1 + y2 + y3)/3; zavg = f(xbar,ybar); I = I + zavg*A; % accumulate integral
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/15/2011 for the course MATH 345 taught by Professor Staff during the Spring '08 term at Ohio State.

Page1 / 7

HW 7 Ben - HW 7 25.1) By changing line 194 to z = (x +...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online