DeGracia_Miguel_19481379_Section22_Lab12

DeGracia_Miguel_19481379_Section22_Lab12 - % Miguel De...

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

View Full Document Right Arrow Icon
%% Miguel De Gracia. 19481379. Section 22. Lab Assignment 12. % clear all clc close all c %% Problem 1a % m = @(W) W.^2; variance = (1/8)*quad(m,2,10) - (6^2); v %% Problem 1b % meanw = 6; meantotal = 1000*meanw; stdL = sqrt(10000*variance); s %% Problem 1c % L = (sum(8*rand(500,10000)+2,2)); L %% Problem 1c i % muL = mean(mean(L)); stdL = std(L,1); s %% Problem 1c ii % type my_PDF t hold on [PDF,x] = my_PDF(L,20); bar(x,PDF) b %% Problem 1c iii % Gaussian = @(x) ((1/(stdL*sqrt(2*pi))).*exp((-((x-(muL))/stdL).^2)/2)); plot(x,Gaussian(x),'r') hold off h %It is a fairly accurate depiction of the bar graph. % %% Problem 1d % probability = 0.5*erfc((60400-muL)/(stdL*sqrt(2))); p %% Problem 2a % type myTrapIntegrator t format long f I1 = @(x) cos(x) + sqrt(x); myTrapIntegrator(I1,0,pi/2,101) m format long
Background image of page 1

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

View Full DocumentRight Arrow Icon
f %% Problem 2b % Ibar = ((pi)^3)/12; relativeerror = @(N) abs((Ibar - myTrapIntegrator(I1,0,pi/2,N))/Ibar); N = [6 11 21 51 101 151 251 501 1001]; trap = zeros(1,length(N)); t for k = 1:length(N); trap(k) = relativeerror(N(k)); end e %% Problem 2c % I2 = @(x) exp(-x.^2); p1 = quad(I2,-2,2); format long disp(p1) p2 = myTrapIntegrator(I2,-2,2,501); disp(p2) format short f %% Problem 2d % type myTrapIntTol t myTrapIntTol(I2,-2,2,10^-5) myTrapIntTol(I2,-2,2,10^-12) m I3=@(x) (sin(x)).^2+exp(cos(x));
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 02/18/2010 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at University of California, Berkeley.

Page1 / 6

DeGracia_Miguel_19481379_Section22_Lab12 - % Miguel De...

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