MATLAB Answers

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

5 views (last 30 days)
MUSTAFA TASKIRAN
MUSTAFA TASKIRAN on 2 Jan 2020
Answered: Image Analyst on 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 Comments

Sign in to comment.

Answers (2)

Rik
Rik on 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 Comments

Sign in to comment.


Image Analyst
Image Analyst on 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 Comments

Sign in to comment.

Sign in to answer this question.

Tags