这里我试图绘制错误(矩阵之间的归一化差异)与变量rho。所有其他变量应保持不变。 我真正想做的是将rho存储为单独的向量,并在每个循环中计算错误时存储错误值。
有什么想法吗?
%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)
'那是你的意思吗?
%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