DeGracia_Miguel_19481379_Section22_Lab12

# DeGracia_Miguel_19481379_Section22_Lab12 - Miguel De Gracia...

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

%% 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

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

View Full Document
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);
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 5

DeGracia_Miguel_19481379_Section22_Lab12 - Miguel De Gracia...

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

View Full Document
Ask a homework question - tutors are online