Data plot with color

9 ビュー (過去 30 日間)
Srijeet Tripathy
Srijeet Tripathy 2018 年 6 月 20 日
コメント済み: Srijeet Tripathy 2018 年 6 月 20 日
Dear Users, I have a set of data of say 100 elements and I want to plot 5% of this data, randomly assigned, in blue and the rest in red. Can you help me? The data I have generated is a collection of random points
% code
m = zeros(1,100);
n = zeros(1,100);
for i = 1:100
m(i) = sqrt((100*rand)^2);
n(i) = sqrt((100*rand)^2);
end
axis ([0 100 0 100])
scatter(m, n);

採用された回答

KSSV
KSSV 2018 年 6 月 20 日
% code
m = zeros(1,100);
n = zeros(1,100);
for i = 1:100
m(i) = sqrt((100*rand)^2);
n(i) = sqrt((100*rand)^2);
end
idx = randperm(100,5) ;
figure
hold on
plot(m(idx),n(idx),'Ob') ;
idx1 = setdiff(1:100,idx) ;
plot(m(idx1),n(idx1),'Or') ;
  1 件のコメント
Srijeet Tripathy
Srijeet Tripathy 2018 年 6 月 20 日
Thanks!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by