Search code examples
matlabmatlab-figure

How can I plot some values of plotted vector in Matlab with different marker?


I have a vector x with 1000 values, plots in matlab using semiology function, I want to change the marker of the values x(1:10:1000) to be different. How can I do that?

I tried to use the following way with using the new marker as circle:

semiology(x(1:10:1000), y(1:10:1000), 'o'); 

but that plots the first 100 values, I mean the new marker will be shown on the first 100 values of older plot, it will not be distributed on the whole old plot. However, I need the new marker to be shown on the same values.


Solution

  • I guess from your question that the orginal plot with all the points is cleared. If so then the command hold on can be used to preserve that plot. for your case:

    semilogy(x, y, 'o'); % Plot the entire vector with the 'o' marker
    hold on; % Do not let semilogy replace the current plot 
    semilogy(x(1:10:1000), y(1:10:1000), 'x'); % mark every 10th point with an 'x'