%% Annotated Matlab transcript -- 4/24 %% CS 323 - Doug DeCarlo % Solving Ax = b A = [1 1 -2; 1 1 1; 1 -1 0] % this needs to be a column vector -- hence the ' b = [3 1 2]'; % Matlab's way of solving linear systems A \ b % you can do it this way to, but it's a lot slower as it builds the inverse inv(A) * b % If b is of this form, we can see how the method for buildling the % inverse works... b = [1 0 0]' format short inv(A) A \ b % LU decomposition is built in, where P is the permutation matrix % so that LU = PA [L,U,P] = lu(A) % we can reconstruct A this way inv(P)*L*U A