Question: Hi, there is an issue with my MATLAB code for this linear algebra project. Probably a loop issue because when I run it MATLAB starts

Hi, there is an issue with my MATLAB code for this linear algebra project. Probably a loop issue because when I run it MATLAB starts to leak memory a bunch. Please find the issue for a guaranteed thumbs up! ;) Thanks for your help!

Here is a link to download a PDF of the instructions: https://drive.google.com/file/d/11XtIAiw0VysXWxa7nNdSIBPIVK22T56-/view?usp=sharing

Here is my code:

%shrink function function B = shrink(A) format compact, [~, pivot] = rref(A); B = A(: , pivot);

%proj function

function p = proj(A,b) format compact, A = shrink(A); b = transpose(b); if size(A,1)==size(transpose(b),2) if rank(A) == rank([A b]) p=transpose(b); disp(p) z=transpose(b)-p; disp(z) disp('b is in the Col A') return else R = colspace(sym(A)); T=0; for i=1:size(R,2) T=T+dot(R(:,i),b); end T=closetozeroroundoff(T); if T == 0 z = transpose(b); p=z-transpose(b); disp(p) disp(z) disp('b is orthogonal to Col A') return else p=(A*((transpose(A)*A)/transpose(A)))*b; disp(p) z=transpose(b)-transpose(p); D=dot(p,z); if abs(d) <1E-7 disp('Yes, p and z are orthogonal! Great job!') else disp('Oops! Is there a bug in my code?') end end end else disp('No solution: dimensions of A and b disagree') p = []; z=[]; end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!