Matlab - designate a specific value along the x axis

I would like to point out a specific value, for example 1.2345 on the x axis, perhaps emphasize it with a larger dot or circle or something similar. How to do it?

+3
source share
2 answers

The answer to this depends on what you draw. If you create a function that you can do:

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

enter image description here

If you are drawing a vector, use INTERP1 to interpolate the data into the 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')

enter image description here

+2
source

One way - to establish XTickand XTickLabel properties of the axes.

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

You can also select a vertical line:

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

+1
source

All Articles