2017-05-19 116 views
3

如何使用MarkerIndicesplotMATLAB圖的MarkerIndices屬性

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', ... 
+0

什麼是版本? – Masoud

+0

@Masoud,版本2015a。 – anonymous

回答

3

MarkerIndices面世R2016b版本。

解決方法是繪製兩次:

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

這應該工作。我評論說這是參考MathWorks社區的一篇文章。將提供一個鏈接,如果找到它。

P.S.這是LINK來的答案;