MATLAB Answers

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

조회 수: 1(최근 30일)
MUSTAFA TASKIRAN
MUSTAFA TASKIRAN 2 Jan 2020
답변: Image Analyst 2 Jan 2020
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

  댓글 수: 0

로그인 to comment.

답변(2개)

Rik
Rik 2 Jan 2020
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.

  댓글 수: 0

로그인 to comment.


Image Analyst
Image Analyst 2 Jan 2020
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.

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.

태그


Translated by