MATLAB Plot graph of different color for different points? Matlab

Click For Summary
To plot a curve in MATLAB with each point in a different color, users can utilize a loop to assign colors dynamically based on the index of each point. The example provided shows how to calculate values iteratively and plot them, but it lacks color differentiation. A suggested approach is to use the 'scatter' function with a colormap, such as 'jet', to assign colors based on the index. By adjusting the size and color parameters in the scatter function, each point can be visually distinct. This method enhances the clarity and aesthetics of the plotted data.
cks
Messages
164
Reaction score
0
I would like to plot a curve with each point with different color.

For example

x0=2;
for i=1:1:200
x1=x0*cos(x0)+exp(x0);
plot(i,x1) (THIS IS THE PLACE WHERE I WANT TO PUT DIFFERENT COLOR)
x0=x1;
end
 
Physics news on Phys.org
scatter(1:10,2:11,50,jet(10))
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
3K