loop not executing
1 回表示 (過去 30 日間)
古いコメントを表示
i have posted the code below ,the k means is plotted for 1st figure remaining 91 figures r white ,k means is noot plotted.please help
X=[out;out1111]
opts = statset('Display','final');
[idx,ctrs]=kmeans(X,10,'Distance','city','Replicates',5,'Options',opts)
v=size(idx)
b=size(ctrs)
for i=1:10
for j=1:10
figure,
plot(X(idx==i,j),X(idx==i,j),'r.','MarkerSize',16)
hold on;
plot(X(idx==i+1,1),X(idx==i+1,2),'b.','MarkerSize',16)
plot(X(idx==i+2,2),X(idx==i+2,3),'g.','MarkerSize',16)
legend('DBLCL','CLL','FLL')
outSS=d1(:,1);
outDD=d1(:,2);
for nn = 1:92
figure,
xlabel(['resp ', num2str(outSS(nn))]);
ylabel(['resp ', num2str(outDD(nn))]);
end
end
end
0 件のコメント
回答 (1 件)
Walter Roberson
2011 年 11 月 8 日
You have
for i = 1:10
for j = 1:10
figure
... do some plotting inside that figure ...
for nn = 1 : 92
figure
... put up two labels
end
end
end
You are thus asking for 10 * 10 + 10 * 10 * 92 figures (total 9300 figures) to be created, and all you are doing with 9200 of them is to put up two labels.
I think you need to reconsider your logic.
2 件のコメント
Walter Roberson
2011 年 11 月 9 日
I matched the "end" statements in the original code carefully. In the original code, the "for nn = 1:92" is _inside_ the i and j loops.
Using your adjusted code, the figure() calls you use in the "for nn" loop will generate _different_ figures than the figure() call in the "for i" / "for j" nested loop.
You say that you need to label the axes for the 100 graphs generated, but you only generate xlabel() and ylabel() for 92 graphs. Why is that?
Anyhow...
outSS=d1(:,1);
outDD=d1(:,2);
for i=1:10
for j=1:10
figure,
plot(X(idx==i,j),X(idx==i,j),'r.','MarkerSize',16)
hold on;
plot(X(idx==i+1,1),X(idx==i+1,2),'b.','MarkerSize',16)
plot(X(idx==i+2,2),X(idx==i+2,3),'g.','MarkerSize',16)
legend('DBLCL','CLL','FLL')
nn = (i-1)*10 + j;
if nn <= 92
xlabel(['resp ', num2str(outSS(nn))]);
ylabel(['resp ', num2str(outDD(nn))]);
end
end
end
though again I don't see where the 92 vs 100 is supposed to fit in.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!