Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How can I see the all results at the same time according to changing values in a "for" loop?

조회 수: 1 (최근 30일)
Hello,
I want to see ,for example, error_f_1 , error_f2_1,error_f3_1, error_f4_1 for all changing sigma values at the same time. Is it a way to do that? When I run the code it is only shown that the final step (sigma=10). Thanks in advance.
[X, labels, t] = generate_data('helix',1000, 0.0);
for k=1:10
data.X=X;
sigma=k;
numDP=size(data.X,1);
% [data]=ball_voteprocess(data,sigma);
data.R=cell(numDP,1);
data.R(:)={eye(size(data.X,2))};
[data]=alternative_voting(data,sigma);
[data]=determine_Dimension(data);
[w,d]=quality_vote(data,sigma);
for i=1:numDP
error1(i)=(w{i}*d{i}')/sum(w{i});
error2(i)=(w{i}*d{i}')/sum(w{i}.^2);
error3(i)=(w{i}*d{i}.^2')/sum(w{i});
error4(i)=(w{i}*d{i}.^2')/sum(w{i}.^2);
end
error_f_1=sum(error1);
error_f2_1=sum(error2);
error_f3_1=sum(error3);
error_f4_1=sum(error4);
end

답변 (2개)

Rik
Rik 2020년 1월 2일
Store the results in an array. Don't use numbered variables, you will either have to type them out (increasing the risk of typos), or use a trick every time you want to use the variable.

Image Analyst
Image Analyst 2020년 1월 2일
Set a breakpoint at the end of the for loop and look in the workspace panel.
Or, take the semicolons off the ends of the lines to have them echo the values to the command window.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by