MATLAB 图的 MarkerIndices 属性

MATLAB plot's MarkerIndices property

如何将 MarkerIndicesplot 一起使用?

x = linspace(-10,10,101);
y = sin(x);

plot(x, y,  'color', 'blue', ...
            'LineStyle','-', ...
            'Marker', 's', ...           
            'MarkerIndices', [1, 5, 10], ...        
            'MarkerEdgeColor', 'black',...
            'MarkerFaceColor','yellow');

错误信息

Error using plot
There is no MarkerIndices property on the Line class.

Error in plotting3 (line 4)
plot(x, y,  'color', 'blue', ...

MarkerIndicesR2016b 版本中可用。

解决方法是绘制两次:

MarkerIndices = [1, 5, 10];
myplot = plot(x, y, 'b-.');
hold on;                 
mymarkers = plot(x(MarkerIndices), y(MarkerIndices), 'ro');    
legend(myplot)

这应该有效。我评论说这是参考 MathWorks 社区上的 post。如果找到,将提供 link。

P.S。这是LINK的答案;