Programming and Graphics

(Kiana) #1

344 Introduction to C++ Programming and Graphics



  • Beginning and end of a command line:
    AMatlabcommand can begin at any position in a line, and may continue
    practically indefinitely in the same line.

  • Line continuation:
    To continue a command onto the next line, we put three dots at the end
    of the line.

  • Multiple commands in a line:
    Two or more commands can be placed in the same line provided they are
    separated with a semicolon (;).

  • Display:
    When a command is executed directly or by running aMatlabcode,
    Matlabdisplays the numerical value assignment or the result of a calcu-
    lation. To suppress the output, we put a semicolon (;) at the end of the
    command.

  • White space:
    More than one empty space between words are ignored by the compiler.
    However, numbers cannot be split in sections separated by blank spaces.

  • Range of indices:
    Vectors and arrays must have positive and non-zero indices; the vector
    entryv(-3)is unacceptable inMatlab. This annoying restriction can
    be circumvented in clever ways by redefining the indices.

  • Comments:
    A line beginning with the%character, or the tail-end of a line after the%
    character, is a comment, and is ignored by theMatlabinterpreter.

  • Mathematical symbols and special characters:
    Table F.1.1 lists mathematical symbols and special characters used in
    Matlabinteractive dialog and programming.

  • Logical control flow commands:
    Table F.1.2 lists the basic logical control flow commands.

  • Input/Output commands:
    Tables F.1.3-5 list basic Input/Output (I/O) commands, functions, and
    formatting statements. Once the output format is set, it remains in effect
    until changed.

Free download pdf