hw4_solutions

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

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full DocumentRight Arrow Icon
-0.1014 0.0725 0 0.0580 0.1014 0 Published with MATLAB® 7.4
Background image of page 2
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 =
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/02/2008 for the course MAE 107 taught by Professor Rottman during the Spring '08 term at UCSD.

Page1 / 9

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online