Page 237 -
P. 237

gives

                                ans =
                                     17  19   23
                                     37  41   47

                             8.1.1.2  Retrieving Special Matrices from the MATLAB Library
                             MATLAB has some commonly used specialized matrices in its library that
                             can be called as needed. For example:

                                • The matrix of size (m ⊗ n) with all elements being zero is
                                   M=zeros(m,n);

                             For example:

                                M=zeros(3,4)

                             gives

                                M =
                                     0000
                                     0000
                                     0000

                                • The matrix of size (m ⊗ n) with all elements equal to 1 is
                                   N=ones(m,n):

                             For example:

                                N=ones(4,3)

                             produces

                                N =
                                     111
                                     111
                                     111
                                     111

                                • The matrix of size (n ⊗ n) with only the diagonal elements equal
                                   to one, otherwise zero, is P=eye(n,n):

                             For example:


                             © 2001 by CRC Press LLC
   232   233   234   235   236   237   238   239   240   241   242