Info

この質問は閉じられています。 編集または回答するには再度開いてください。

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 2020 年 1 月 2 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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