Ask Your Question

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

asked 2022-08-30 11:00:00 +0000

lalupa gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-08-01 18:00:00 +0000

plato gravatar image

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:


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:


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

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2022-08-30 11:00:00 +0000

Seen: 8 times

Last updated: Aug 01 '22