How graph using for loop

조회 수: 2 (최근 30일)
Dionisio Mendoza
Dionisio Mendoza 2019년 2월 8일
편집: Dionisio Mendoza 2019년 2월 15일
it is possible to classify the data of a graph using the for loops?
For example so that the data of this graph if they paint four different colors ( x> 90 y<90, another x> 90 y> 90, another x<90 y<90,another x<90 y> 90)
x=-100+(100+100)*rand(1500,1);
y=-100+(100+100)*rand(1500,1);
plot(x,y,'or')

채택된 답변

KSSV
KSSV 2019년 2월 8일
Read about kmeans
x=-100+(100+100)*rand(1500,1); %Un vector de 1500 renglones x 1 fila, que muestra nuemros random desde -100 a 100
y=-100+(100+100)*rand(1500,1); %Otro vector de 1500 renglones x 1 fila, qu mustra numeros random dl-110 al 100
plot(x,y,'or')
title('Numeros Aleatorios entre -100 y 100','color','green')
idx = kmeans([x y],4) ;
figure
hold on
for i = 1:4
plot(x(idx==i),y(idx==i),'.','color',rand(1,3)) ;
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by