# What is the method for plotting certain values of a plotted vector with varied markers in Matlab?

edit retag close merge delete

Sort by » oldest newest most voted

In Matlab, you can plot certain values of a plotted vector with varied markers using the "plot" function with the option to specify a vector of markers using the 'Marker' property.

Here's an example:

Suppose you have a vector of data points:

x = 1:10; y = x.^2;

To plot all of the points with the same marker style, you can simply use the 'plot' function without specifying a marker:

plot(x,y)

To plot certain values (e.g. the even values) with a different marker style, you can create a vector of markers representing the style for each point, using the 'Marker' property:

markers = repmat('o',1,10); %create a 1x10 vector of circles markers(2:2:end) = 's'; %change every other marker to a square

Then, you can use the 'plot' function again, but this time specify both the data points and the markers to use:

plot(x,y,'Marker',markers)

This will plot the data points with circles for odd values and squares for even values.

more