{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw4_solutions

# hw4_solutions - MAE 107 Spring 2007 HW 4 Problem 1 Contents...

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

MAE 107 Spring 2007 HW 4 Problem 1 Contents The terms can be collected to give: The terms can be collected to give: A = [0 -7 5;0 4 7;-4 3 -7] b = [50;-30;40] x = A\b AT = A' % transpose AI = inv(A) % inverse A = 0 -7 5 0 4 7 -4 3 -7 b = 50 -30 40 x = -15.1812 -7.2464 -0.1449 AT = 0 0 -4 -7 4 3 5 7 -7 AI = -0.1775 -0.1232 -0.2500

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

View Full Document
-0.1014 0.0725 0 0.0580 0.1014 0 Published with MATLAB® 7.4
MAE 107 Spring 2007 HW 4 Problem 2 Contents Function to multiply two matrices Test mat_mult for matrices from Prob 8.4 Function to multiply two matrices type mat_mult.m % function to multiply two matrices function X=mat_mult(Y,Z) if nargin < 2 disp('at least 2 input arguments required'); return end [m,n]=size(Y); [n2,p]=size(Z); if n ~= n2 disp('Inner matrix dimensions must agree.'); return end for i = 1:m for j = 1:p s=0; for k=1:n s=s+Y(i,k)*Z(k,j); end X(i,j)=s; end end end Test mat_mult for matrices from Prob 8.4 A = [6 -1;12 8;-5 4] B = [4 0;0.5 2] C = [2 -2;-3 1] mat_mult(A,B) mat_mult(A,C) mat_mult(B,C) mat_mult(C,B) mat_mult(B,A) mat_mult(C,A) A =

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

View Full Document
6 -1 12 8 -5 4 B = 4.0000 0 0.5000 2.0000 C = 2 -2 -3 1 ans = 23.5000 -2.0000 52.0000 16.0000 -18.0000 8.0000 ans = 15 -13 0 -16 -22 14 ans = 8 -8 -5 1 ans = 7.0000 -4.0000 -11.5000 2.0000 Inner matrix dimensions must agree.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 9

hw4_solutions - MAE 107 Spring 2007 HW 4 Problem 1 Contents...

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

View Full Document
Ask a homework question - tutors are online