0

Here I'm trying to plot the error (normalized difference between matrices) against the variable rho. All other variables should remain constant. What I'd really like to do is store rho as a separate vector and store values for the error as they're being calculated in each loop.

Any ideas?

%Variables:
%MatrixGen.m:   p,q - matrix size, rho- percentage complete, r - rank
%NuclearNorm.m :   Zincomplete

clear

p=10; q=10;
r=2;

for rho=0.1:0.3:0.9;

    [Ztrue, Zincomplete] = MatrixGen(p,q,r,rho)

    tic
    [Zreconstructed] = NuclearNorm(Zincomplete)
    toc

    Error= norm(Ztrue-Zreconstructed, 'fro')

    hold on
    plot (rho, Error)

end
0

1 Answer 1

1

'Is that what you meant?

%Variables:
%MatrixGen.m:   p,q - matrix size, rho- percentage complete, r - rank
%NuclearNorm.m :   Zincomplete

clear
p=10; q=10;
r=2;

rho = 0.1:0.3:0.9
errors = zeros(size(rho))

for i=1:length(rho);

    [Ztrue, Zincomplete] = MatrixGen(p,q,r,rho(i))

    tic
    [Zreconstructed] = NuclearNorm(Zincomplete)
    toc

    errors(i) = norm(Ztrue-Zreconstructed, 'fro')
end

plot(rho, errors)

end
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.