# project2 - % N L h x o V M = = = = = = = 1000; 10; L/(N-1);...

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

%% N = 1000; L = 10; h = L/(N-1); x = linspace(0,L,N); o = [5, 1, 0.1, 0.001]; V = zeros(length(o),length(x)); M = zeros(length(o),length(x)); for k = 1:length(o) for i = 1:length(x) w(k,i) = 10.*exp((-((x(i))-5).^2)./(2.*o(k))); end end figure hold on title('w(x) for various sigma') xlabel('x') ylabel('w(x)') plot(x,w(1,:),'b') plot(x,w(2,:),'r') plot(x,w(3,:),'g') plot(x,w(4,:),'m') hold off legend('sigma 5','sigma 1','sigma 0.1','sigma 0.001') %% Initial condition V(x) % for i=1:length(o) % for k=1:(length(x)-1) % V(i,1) = V(i,1) + (h/6)*(w(i,k)+4*(1/2)*(w(i,k)+w(i,k+1))+w(i,k+1)); % end % end % % % for i=1:length(o) % for k=1:(length(x)-1) % V(i,k+1) = V(i,1) + (h/6)*(w(i,k)+4*(1/2)*(w(i,k)+w(i,k+1))+w(i,k+1)); % end % end W = @(X,sig)(10.*exp((-((X)-5).^2)./(2.*sig))); for ii= 1:4 sigma = [5 1 0.1 0.01]; sigma = sigma(ii); wtemp= @(X)(10.*exp((-((X)-5).^2)./(2.*sigma))); vtemp= @(lim)(quad(wtemp,0,lim)); for jj=2:length(x) V(ii,jj)=vtemp((x(jj))); end end

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

View Full Document
figure hold on title('V(x) for various sigma')
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 / 3

project2 - % N L h x o V M = = = = = = = 1000; 10; L/(N-1);...

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

View Full Document
Ask a homework question - tutors are online