Page 236 -
P. 236

To find the size of the matrix (i.e., the number of rows and columns), enter:

                                size(M)

                             gives

                                ans =
                                     35

                              To view a particular element, for example, the (2, 4) element, enter:

                                M(2,4)


                             gives

                                ans =
                                     23

                             To view a particular row such as the 3  row, enter:
                                                              rd
                                M(3,:)

                             gives

                                ans =
                                     31  37   41  47   53

                                                                 th
                             To view a particular column such as the 4  column, enter:
                                M(:,4)

                             gives


                                ans =
                                      7
                                     23
                                     47

                              If we wanted to construct a submatrix of the original matrix, for example,
                                                             nd
                                                                  rd
                             one that includes the block from the 2 to 3 row (included) and from the 2 nd
                             column to the 4 column (included), enter:
                                          th
                                M(2:3,2:4)

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