%% An Example Write Up in Matlab % %% Solving a Least Squares problem in Matlab % % Descriptive Sample Text % We can even include LaTeX code (we'll be exporting to Latex later): % % % \begin{tabular}{|c|c|} % \hline % Letter & Output\\ % \hline % T & $-60$\\ % G & $0$\\ % F & $60$\\ % \end{tabular} % %% Initialize the matrix A and desired outputs t. N=100; %Number of points to use A=[2*randn(N,1)-1, randn(N,1)+2]; t=3*A(:,1)-2*A(:,2)+0.01*randn(N,1); %% Form the normal equations and solve: % c=inv(A'*A)*A'*t c2=A\t %% Look at the error out1=A*c; out2=A*c2; plot(1:N,out1,1:N,out2)