Page 18 - Basics of MATLAB and Beyond
P. 18

matlab will recall the last command that began with those characters.
                               Subsequent use of ↑ will recall earlier commands that began with those
                               characters.

                               2.3   Long Lines
                               If you want to type a matlab command that is too long to fit on one
                               line, you can continue on to the next by ending with a space followed by
                               three full stops. For example, to type an expression with long variable
                               names:

                               Final_Answer = BigMatrix(row_indices,column_indices) + ...
                                               Another_vector*SomethingElse;
                               Or to define a long text string:

                               Mission = [’DSTO’’s objective is to give advice that’ ...
                               ’is professional, impartial and informed on the’ ...
                               ’application of science and technology that is best’ ...
                               ’suited to Australia’’s defence and security needs.’];


                               2.4   Copying and Pasting
                               Your windowing system’s copy and paste facility can be used to enter
                               text into the matlab command line. For example all of matlab’s built-
                               in commands have some helpful text that can by accessed by typing help
                               followed by the name of the command. Try typing help contour into
                               matlab and you will see a description of how to create a contour plot.
                               At the end of the help message is an example. You can use the mouse
                               to select the example text and paste it into the command line. Try it
                               now and you should see a contour plot appear in the figure window.

                               3    Matrices


                               3.1   Typing Matrices
                               To type a matrix into matlab you must

                                  • begin with a square bracket [
                                  • separate elements in a row with commas or spaces

                                  • use a semicolon ; to separate rows
                                  • end the matrix with another square bracket ].
                               For example type:





                               c   2000 by CRC Press LLC
   13   14   15   16   17   18   19   20   21   22   23