Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
MUSTAFA TASKIRAN
MUSTAFA TASKIRAN le 2 Jan 2020
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (2)

Rik
Rik le 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.

Image Analyst
Image Analyst le 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.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by