MATLAB: How to plot |x|<=1 and |y|<=1 with X and Y rational numbers

how to plot rational numbersMATLAB

^

Best Answer

You cannot do so. Or, what you can do is pretty boring.
Between any pair of rational numbers, there are infinitely many irrational numbers. But there are also infinitely many rational numbers in that interval. In fact, between any pair of irrational numbers, there are infinitely many rational numbers. And that is just on the number line. In two dimensions, nothing really changes.
So the "plot" that you desire is just the square defined by those constraints, except that you would need to exclude infinitely many points. The plot that you desire to have is sort of an infinitely holey swiss cheese.
Sorry, but your request makes no sense in terms of mathematics.
How about in terms of MATLAB? What does your question mean? Well EVERY point on the number line, when represented in MATLAB is now a number represented by a finite number of bits, since the number is stored in a binary format. Therefore EVERY floating point number in MATLAB is in fact a "rational" number, when viewed in floating point arithmetic. Therefore the plot you want to construct is just the complete square bounded by +/- 1 in both x and y. Every single point that can be represented in that square has both x and y rational numbers, when viewed as floating point numbers.
Of course, even then the plot that you might then try to construct is still a holey piece of swiss cheese, since between any pair of points that can be represented in floating point arithmetic, there are still infinitely many (unrepresented and unrepresentable) points that are rational AND infinitely many unrepresented and unrepresentable points that are irrational.
So while I have no idea what you really want to do, what you have asked to do still makes very little sense.
Related Question