clear % the backslash command A=[3 1 4 6; 3 5 6 2; 8 9 0 54; 3 5 734 2]; bq=[3; 5; 6; 7]; xq=A\bq; %type format rat to get this in fractional form % sometimes it goes wrong G=[0 0; 0 0]; g=[1;2]; y=G\g; % check out xlsread for reading data etc. from excel files % checking sdd with a function R=[4 -1 1; 4 -8 1; -2 1 5]; verify=checksdd(R) if verify==1 ee=3 else ee=0 end % solvin Ax=b with LU factorization Q=[3 4 5; 6 7 2; 3 1 6]; m=length(Q); b(1:m,1)=[3; 4; 5]; b(1:m,2)=[1; 2 ; 3]; b(1:m,3)=[4; 5; 6]; [L, U, P]=lu(Q); tic %turn on stopwatch for i=1:3 if P==eye(m) x(1:m,i)=U\(L\b(:,i)); else x(1:m,i)=U\(L\(P*b(:,i))); end end t1=toc %turn off stopwatch tic for i=1:3 x2(1:m,i)=Q\b(:,i); end t2=toc