Matlab - mark a particular value on x-axis
I would lik开发者_Go百科e to mark a specific value, say 1.2345 on the x-axis, perhaps emphasize it with a bigger dot or a circle or something similar. How do I do this?
The answer to this depends on what you're plotting. If you're plotting a function you could do:
>> fplot(@sin, [0 2]) >> hold on >> plot(1.2345, sin(1.2345), 'ro')

If you're plotting a vector, then use INTERP1 to interpolate the data to your target x value:
>> 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')

One way is to set the XTick and XTickLabel properties of the axes.
set(gca, 'XTick', [0 1 1.2345 2]);
You might also want to draw a vertical line:
line(x0*[1 1], get(gca,'YLim'))
加载中,请稍侯......
精彩评论