labelling X and Y axis
1 次查看(过去 30 天)
显示 更早的评论
I have plotted the k means graph ,i have 100 graphs ,now i want to label xand y axis
for 1st graphthe X ,Y axis must 1&101resp
for 2nd graph the X ,Y axis must 2&102resp
;
;
;
for 100thy graph X,Y axis must be 100&200resp
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
0 个评论
采纳的回答
Daniel Shub
2011-11-8
The formatting of your question is a little off, but I think you want ...
xlabel([num2str(((i-1)*10)+j), 'resp'])
ylabel([num2str(((i-1)*10)+j+100), 'resp'])
Just add it after your plot commands.
2 个评论
Daniel Shub
2011-11-8
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'])
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graph and Network Algorithms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!