## get 2 set of random coordinates

Elysi Cochin

### Elysi Cochin (view profile)

さんによって質問されました 2019 年 1 月 24 日

さんによって 編集されました 2019 年 1 月 24 日

さんの 回答が採用されました
How to plot as above randomly with two colors
I have now given
xy = [2.5 4.5;
3.5 4.5;
4.5 4.5;
4.5 2.5;
3.5 3.5];
and plotted
what should i do to get 2 set of random coordinates and plot as shown in image attached. All locations should have a plot

#### 2 件のコメント

2019 年 1 月 24 日
Your title seems like you want to choose 2 colors randomly but the last sentence seems like you want to produce random coordinates. Can you explain the problems again?
Elysi Cochin

### Elysi Cochin (view profile)

2019 年 1 月 24 日
i want to select 2 set of random coordinates

サインイン to comment.

## 1 件の回答

2019 年 1 月 24 日

2019 年 1 月 24 日
採用された回答

In this demo, I create a grid of coordinates identical to the plot in your question. Then I randomly select a subsection of them. Then I plot that subsection in red and the remaining coordinates in black.
%Produce coordinates
[x, y] = meshgrid( [1.5:1:5], [1.5:1:5]);
% randomly select a subset of coordinates
idx = logical(randi([0 1], size(x)));
% plot each subset
figure
plot(x(idx), y(idx), 'ro', 'markersize', 15, 'linewidth', 2);
hold on
plot(x(~idx), y(~idx), 'ko', 'markersize', 15, 'linewidth', 2);
xlim([1, 5])
ylim([1, 5])