Can this ‘rat()’-function find all 3 ratios, but with same denominator?
[n,d]=rat([y0,x1,y1],ma)
I had some solution to this as in below code, but not sure if that is how to solve this issue: plot_polygon.m (909 Bytes)

I was going to ask about taking the LCM of the denominators but I see you’re already doing that. There isn’t a better method for that.

From your code it looks like you’re trying to snap certain points to the nearest 0.01 in the grid. It would be easier to do round (x * 100) / 100 instead of going through rat and lcm. You’re not using the rational numbers except to snap to grid.