2011-03-17 63 views
3

我想标记特定值的特定值,即在X轴1.2345,或许还有一个更大点或圆或类似的东西强调这一点。我该怎么做呢?Matlab的马克 - 在x轴上

回答

2

这个问题的答案取决于你绘制的。如果您在绘制函数,你可以这样做:

 
>> fplot(@sin, [0 2]) 
>> hold on 
>> plot(1.2345, sin(1.2345), 'ro') 

enter image description here

如果您在绘制矢量,然后用INTERP1的数据插值到目标的x值:

 
>> x = 0:.1:2; 
>> y = sin(x); 
>> figure 
>> plot(x, y, '.-') 
>> yi = interp1(x, y, 1.2345) 

yi = 

     0.942913175277465 

>> hold on 
>> plot(1.2345, yi, 'ro') 

enter image description here

+1

+1。 @Viktor:如果你真的想要'x轴',在这个例子中你会使用'plot(1.2345,0,'ro')'。 – Ramashalanka 2011-03-17 18:05:28

+0

将此与'set(gca,'XTick',[0 1.2345 2])'结合。 – nibot 2011-03-18 04:43:35

1

一种方法是设置一个的XTickXTickLabelproperties XES。

set(gca, 'XTick', [0 1 1.2345 2]);

你也可能要画一条竖线:

line(x0*[1 1], get(gca,'YLim'))