Filter löschen
Filter löschen

could anyone help me to solve the issue

2 Ansichten (letzte 30 Tage)
jaah navi
jaah navi am 28 Feb. 2019
Bearbeitet: Walter Roberson am 1 Mär. 2019
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 Kommentar
Jan
Jan am 28 Feb. 2019
I've formatted your code today to make it readable. Please do this by your own in following questions. Thanks.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 28 Feb. 2019
'[.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 Kommentare
Jan
Jan am 28 Feb. 2019
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 am 1 Mär. 2019
Bearbeitet: Walter Roberson am 1 Mär. 2019
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by