# shear - x = linspace(0,L,N h = L(N-1 o =[5 1 0.1 0.001...

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

%% Miguel De Gracia. 19481379. Assignment #2. % %% Plotting w(x) % N = 1000; L = 10; x = linspace(0,L,N); h = L/(N-1); o = [5, 1, 0.1, 0.001]; V=zeros(1,length(x)); M=zeros(1,length(x)); M for k = 1:length(o) for i = 1:length(x) w(k,i) = 10.*exp((-((x(i))-5).^2)./(2.*o(k))); end end e 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') p legend('sigma 5','sigma 1','sigma 0.1','sigma 0.001') l %% Solving for V(x) % w = w(1,:); w for i=1:N-1 V(1)=V(1)+((h/6)*(w(x(i))+4*(1/2)*(w(x(i))+w(x(i+1)))+w(x(i+1)))); M(1)=M(1)+((h/6)*(-x(i)*w(x(i))-((x(i)+x(i+1))/2)*4*w((x(i)+x(i+1))/2). .. -x(i+1)*w(x(i+1)))); end V(1); M(1); M for k=1:N-1 for j=1:k V(k+1) = V(k+1). .. +((h/6)*(-w(x(j))-4*(1/2)*(w(x(j))+w(x(j+1)))-w(x(j+1)))); end V(k+1) = V(k+1) + V(1); end e for g=1:N-1

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

View Full Document
for f=1:g M(g+1)=M(g+1)+((h/6)*(V(f)+4*(1/2)*(V(f)+V(f+1))+V(f+1))); end M(g+1)=M(g+1)+M(1); end e figure plot(x,V) p figure plot(x,M) p % N = 1000; % L = 10;
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % x = linspace(0,L,N); % h = L/(N-1); % o = [5, 1, 0.1, 0.001]; % V=zeros(1,length(x)); % M=zeros(1,length(x)); % % for t = 1:length(o) % for i = 1:N-1 % % V(t,1) = V(1) + ((h/6).*((w(t,x(i)) + ((4).*((w(t,x(i)) + w(t,x(i+1)))./2)) + w(t,x(i+1))))); % % M(t,1) = M(1) + ((h/6).*(-x(i)*w(t,x(i)) - ((x(i)+x(i+1))./2).*4.*w(t, ((x(i)+x(i+1))./2)) - x(i+1).*w(t,x(i+1)))); % % V(1)=V(1)+((h/6)*(w(x(i))+4*(1/2)*(w(x(i))+w(x(i+1)))+w(x(i+1)))); % M(1)=M(1)+((h/6)*(-x(i)*w(x(i))-((x(i)+x(i+1))/2)*4*w((x(i)+x(i+1))/2)-x(i+1)*w(x(i+1)))); % end % end % V(1); % M(1); % % % for k=1:N-1 % for j=1:k % V(k+1) = V(k+1). .. % +((h/6)*(-w(x(j))-4*(1/2)*(w(x(j))+w(x(j+1)))-w(x(j+1)))); % end % V(k+1) = V(k+1) + V(1); % end % % hold on % plot(x,V) % % % % % Solving for M(x) % % % for g=1:N-1 % for f=1:g % M(g+1)=M(g+1)+((h/6)*(V(f)+4*(1/2)*(V(f)+V(f+1))+V(f+1))); % end % M(g+1)=M(g+1)+M(1); % end %...
View Full Document

## This note was uploaded on 02/18/2010 for the course ENGINEERIN 7 taught by Professor Patzek during the Spring '08 term at Berkeley.

### Page1 / 3

shear - x = linspace(0,L,N h = L(N-1 o =[5 1 0.1 0.001...

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

View Full Document
Ask a homework question - tutors are online