I'm trying to write a code that detrmine the physical lateral distance between a press of a button to specific target on the middle of the screen.
I'm using the next code:
cp = get(gca,'CurrentPoint');
dist = (LinePosition - cp(1));
LinePosition is the distance in centimeters of the middle of the screen from the left edge of the primary display to the inner left edge of the monitor using "MonitorPosition" property.
My problem is that on different monitors i.e on different sizes, resolution and definitions, I get different percentages deviations.
I measured with a ruler the length from the click and compared it to the distance that the code had provided.
On DELL P2317H which is 23 inch on 1920x1080 and 100% 0n the display settings (recommended) I get no significant deviation
On the same DELL, still 1920x1080 but with 125% 0n the display settings I get deviation of 20% approx
On Lenovo Yoga 7 screen which is 14 inch on 1920x1080 and 150% 0n the display settings (recommended) I get deviation of +9% approx
On the same Lenovo screen still 1920x1080 but with 125% I get deviation of +30% approx
On the same Lenovo screen still 1920x1080 but with 175% I get deviation of -6.5% approx (lenghs are shorter)
On Asus X541U screen which is 1366x768 and 100% 0n the display settings (recommended) I get deviation of +4% approx
I will note that I read a lot of documents and searched as much as I could for questions and answers related to the topic but did not find a solution that would meet my need for the code to run on different monitors with different settings