could anyone help me to solve the issue

2 次查看(过去 30 天)
Input of the code are as given below:
N_UE=[6]%no of users
PPP =[ -0.0457 0.0814;
-0.1931 2.3985;
1.8712 1.2803;
-0.4831 1.0973;
1.5610 2.4849;
1.2560 1.2499]%x-coordinate and y-coordinate with respect to 6 users.
a=1
c =[1;
3;
2;
4;
1;
2]
centroids=4
cluster_colors = Columns 1 through 12
'm' 'g' 'y' 'b' 'r' 'c' 'k' '[.5 .6 .7]' '[.2 .3 .4]' '[.1 .2 .3]' '[.7 .8 .9]' '[.6 .4 .3]'
Columns 13 through 17
'[.4 .5 .6]' '[.7 .8 .9]' '[0.5 0 0]' '[0 0.5 0]' '[0 0 0.5]'
A =[3;
1;
1;
0;
3;
0]
with respect to the input I run the following code and got the graph.
code:
figure
plot(PPP(:,1),PPP(:,2),'k*')
hold on
for cc=1:centroids
plot(PPP(c(:,a)==cc,1),PPP(c(:,a)==cc,2),'o','color',cluster_colors{cc});
end
figure
plot(1:N_UE,A,'-*')
The first 1.jpg is correct
with respect to the 2.jpg the location of N_UE is correct.But all appears in same color
But it should have the different number of color as shown in 1.jpg.
Could anyone please help me on this.
  1 个评论
Jan
Jan 2019-2-28
I've formatted your code today to make it readable. Please do this by your own in following questions. Thanks.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2019-2-28
'[.4 .5 .6]' is not a valid color definition. Define it as numerical vector - without quotes:
cluster_colors = {'m', 'g', 'y', 'b, 'r', 'c', 'k', [.5 .6 .7]}
  3 个评论
Jan
Jan 2019-2-28
I do not see, how you have created the two image files. Do you mean the one created by plot(1:N_UE,A,'-*')? Which colors do you expect for the line? Which star should have which color? I assume, you can simply use the loop as in the otehr case also.
jaah navi
jaah navi 2019-3-1
编辑:Walter Roberson 2019-3-1
the first image is created using
plot(PPP(:,1),PPP(:,2),'k*')
followed by
plot(PPP(c(:,a)==cc,1),PPP(c(:,a)==cc,2),'o','color',cluster_colors{cc});
PPP generates 6 stars using the values of x and y coordinates.
cc indicates how many colors to be formed.
with respect to my code cc=4.
so totally 4 colors need to be formed with respect to 6 stars.To identify which star has the same color can be done using c.
By this which star should have the same color has be created.
with respect to the second image using plot(1:N_UE,A,'-*') creates the number of users which is 6 on the axis with respect to A.
As from the first image which user should have which color are identified the same color should appear for the user in the second image.
could you please help me on this.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 2-D and 3-D Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by