To plot multiple plots with different colors of a function in Matlab, you can do the following:
y = sin(x)
.Here's an example code snippet that demonstrates this:
main.m640 chars25 lines
Note that in the plot()
function, the third argument colors(i)
is used to specify the color of the plot for each iteration of the loop. The hold on
and hold off
commands are used to enable and disable the hold behavior, respectively, which allows multiple plots to be displayed on the same figure.
This code snippet will generate a plot with multiple lines, each line using a different color from the colors
array.
gistlibby LogSnag