Asked by Jaikrishnan Mahalekshmi Sahasranamam
on 17 Jul 2019

I have a plot (attached). In this plot I need to add two data cursors. In one of the data cursor, I need to fix the X value to be 0 and in the other i need to fix the y value to 0. How can I adjust the data cursor points to do so? currently in the first data tip, the Y value is -49.51 and in the other data tip the x value is 0.485. I need to make it in such a way as to keep Y value 0 in first and X value 0 in second. By doing this I will get the corresponding X value from 1st and corresponding Y value from 2nd

Answer by Dinesh Yadav
on 2 Aug 2019

Accepted Answer

I am assuming you have the equation used for plotting. You can feed the value “x=0” in the function to get the value of “y” and vice versa and store these values in variable “pos1” and “pos2”. Without having the values for both “x” and “y” you cannot obtain the DataCursor on the plot.

I am attaching a slightly modified code for your given code with which you can obtain DataCursor at any point of your choice. I have commented few lines that are not needed and changed few lines of code for updating DataCursors.

Jaikrishnan Mahalekshmi Sahasranamam
on 5 Aug 2019

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Walter Roberson (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/472124-how-can-i-customly-fix-the-data-cursor-location-in-the-matlab-plot#comment_727243

## Jaikrishnan Mahalekshmi Sahasranamam (view profile)

## Direct link to this comment

https://ch.mathworks.com/matlabcentral/answers/472124-how-can-i-customly-fix-the-data-cursor-location-in-the-matlab-plot#comment_727416

Sign in to comment.