Es240_test2_solution_1_fall10-3

# Es240_test2_solution_1_fall10-3 - % ES 240 % Fall 2010 %...

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: % ES 240 % Fall 2010 % Test 2 %Obtain a blank slate clear all; close all; clc; %a) In Matlab, create the coefficient and right hand matrices (display on the command window) disp ('1A') A=[16 -5 0 0; -5 15 -1 0; 0 -1 11 -5; 0 0 -5 15] B = [0;0;0;-10] %Let user digest solution pause %b) Determine the values of i1, i3, i3, i4 using Matlabs back divide method disp ('1B') Mat_Soln = A\B %Let user digest solution pause %c) Determine the values of i1, i3, i3, i4 using Gaussian Elimination (step by step using colon operations) disp ('1C') %Combine the Coefficient and RHS AB = [A B] %Carryout forward elimination AB(2,:) = AB(2,:) - AB(2,1)/AB(1,1)*AB(1,:) AB(3,:) = AB(3,:) - AB(3,1)/AB(1,1)*AB(1,:) AB(3,:) = AB(3,:) - AB(3,2)/AB(2,2)*AB(2,:) AB(4,:) = AB(4,:) - AB(4,1)/AB(1,1)*AB(1,:) AB(4,:) = AB(4,:) - AB(4,2)/AB(2,2)*AB(2,:) AB(4,:) = AB(4,:) - AB(4,3)/AB(3,3)*AB(3,:) %Carryout forward elimination x(4) = AB(4,5)/AB(4,4) x(3) = (AB(3,5)-AB(3,4)*x(4))/AB(3,3) x(2) = (AB(2,5) - AB(2,4)*x(4) - AB(2,3)*x(3))/AB(2,2) x(1) = (AB(1,5) - AB(1,4)*x(4) - AB(1,3)*x(3) - AB(1,2)*x(2))/AB(1,1) %Let user digest solution pause %d) Determine the values of i1, i3, i3, i4 using the Gauss Jordan Method (step by step using colon operations) disp('1D') %Combine coefficient and RHS again since it was modified from previous AB = [A B] %pivot around first column %but first normalize diagonal entry (make it 1) AB(1,:) = AB(1,:)/AB(1,1) %now make other entries zero AB(1,:) = AB(1,:) / AB(1,1) AB(2,:) = AB(2,:) - AB(2,1)*AB(1,:) AB(3,:) = AB(3,:) - AB(3,1)*AB(1,:)...
View Full Document

## This note was uploaded on 09/04/2011 for the course ENGINEERIN 240 taught by Professor Druche during the Spring '11 term at Montgomery College.

### Page1 / 6

Es240_test2_solution_1_fall10-3 - % ES 240 % Fall 2010 %...

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

View Full Document
Ask a homework question - tutors are online