mark the first point of a plot in a new colour in matlab

You can mark the first point of the plot in a new color by using the following code:

main.m
x = 0:0.1:2*pi;  % example data
y = sin(x);

plot(x, y)  % plot the data

hold on  % hold the current plot

plot(x(1), y(1), 'ro')  % mark the first point of the plot in red

hold off  % release the current plot
212 chars
11 lines

In this code, we first define some example x and y data. We then plot this data using the plot function. We turn on hold with the hold on command, so that we can add another plot object to the existing plot. We then use the plot function again, but this time only plot the first element of x and y in red by using the 'ro' option. Finally, we release the hold with the hold off command. The resulting plot should have the first point marked in red.

gistlibby LogSnag