loop not executing

1 visualización (últimos 30 días)
FIR
FIR el 8 de Nov. de 2011
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

Respuestas (1)

Walter Roberson
Walter Roberson el 8 de Nov. de 2011
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 comentarios
FIR
FIR el 9 de Nov. de 2011
no walter i need only 100 graphs the code for that is
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')
end
end
for those 100 graphs generated i need to label their axis ,i have stored them in two separate variables
outSS=d1(:,1);
outDD=d1(:,2);
for nn = 1:92
figure,
xlabel(['resp ', num2str(outSS(nn))]);
ylabel(['resp ', num2str(outDD(nn))]);
end
if i run these two programs separately i get good result,but wen i make these two program as one full program i get ,error,please help
Walter Roberson
Walter Roberson el 9 de Nov. de 2011
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.

Iniciar sesión para comentar.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by