labelling X and Y axis from another variables

10 ビュー (過去 30 日間)
FIR
FIR 2011 年 11 月 8 日
I have plotted the k means graph ,i have 100 graphs ,now i want to label xand y axis
those values are in a variable A &B
A=[1 to 100 not in same order]
B=[101 to 200 not in same order]
how to name the x and y axis from this please help
for 1st graph X ,Yaxis label must be 1st values in A,B
for 2ndgraph X ,Yaxis label must be 2nd values in A,B ; ; ; for 100th X ,Yaxis label must be 100th values in A,B
I have posted the coding
clc
a=(25*rand(10,10))
b=(89*rand(10,10))
X=[a;b]
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)
end
end
please provide some suggestions

回答 (1 件)

Daniel Shub
Daniel Shub 2011 年 11 月 8 日
Isn't this the same question you asked before (and accepted my answer)? I will give you the same answer again ...
Basically, the current plot number iplot is ((i-1)*10)+j
iplot = ((i-1)*10)+j;
For you, this goes between 1 and 100. You want to convert your labels into strings. You need to be a little careful about the number of significant digits when you convert them
Alabel = sprintf('%f', A(iplot));
Blabel = num2str('%f', B(iplot));
Finally, you need to combine Alabel and Blabel with any other text.
xlabel(['PreXText ', Alabel, ' PostXText'])
ylabel(['PreYText ', Blabel, ' PostYText'])
  1 件のコメント
FIR
FIR 2011 年 11 月 8 日
Daniel i accepted your answer for that question ,which worked very good ,this is another question,
the x and y parameters for x and y axis are stored in a variable A,B
A has numbers from 1 to 100 randomly
B has numbers from 101 to 200 randomly
now i want to take parameters from A,B for each graph and label them

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by