Current location - Training Enrollment Network - Mathematics courses - How to draw a scatter diagram of a function with matlab, so that each point can display different colors according to its own needs?
How to draw a scatter diagram of a function with matlab, so that each point can display different colors according to its own needs?
All closed; Clear all;

x =- 10: 10;

y = sin(x);

Figure;

Hold on;

Plot(x, y,' color',' r');

For n = 1: length (x)

if((x(n)= =-6)| |(x(n)= =-2)| |(x(n)= = 0)| |(x(n)= = 10))

Plot(x(n), y(n),' mark','.',' MarkerSize', 20,' color',' b');

other

plot(x(n),y(n),' Marker ',' o ',' MarkerSize ',7,' color ',' r ')

end

end

How's it going? Am I awesome ~ ~ ~