www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ExpressArrayElementsasRatiosExample.m
%% Express Array Elements as Ratios %% % Create a 4-by-4 matrix. format short; X = hilb(4) %% % Express the elements of |X| as ratios of small integers using |rat|. [N,D] = rat(X) %% % The two matrices, |N| and |D|, approximate |X| with |N./D|. %% % View the elements of |X| as ratios using |format rat|. format rat X %% % In this form, it is clear that |N| contains the numerators of each % fraction and |D| contains the denominators.