12.07.2015 Views

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

GNU Octave - Local Sector 7 web page

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4: Numeric Data Types 334 Numeric Data TypesA numeric constant may be a scalar, a vector, or a matrix, and it may contain complexvalues.The simplest form of a numeric constant, a scalar, is a single number that can be aninteger, a decimal fraction, a number in scientific (exponential) notation, or a complexnumber. Note that all numeric constants are represented within <strong>Octave</strong> in double-precisionfloating point format (complex constants are stored as pairs of double-precision floatingpoint values). Here are some examples of real-valued numeric constants, which all have thesame value:1051.05e+21050e-1To specify complex constants, you can write an expression of the form3 + 4i3.0 + 4.0i0.3e1 + 40e-1iall of which are equivalent. The letter ‘i’ in the previous example stands for the pureimaginary constant, defined as √ −1.For <strong>Octave</strong> to recognize a value as the imaginary part of a complex constant, a spacemust not appear between the number and the ‘i’. If it does, <strong>Octave</strong> will print an errormessage, like this:octave:13> 3 + 4 iparse error:3 + 4 i^You may also use ‘j’, ‘I’, or ‘J’ in place of the ‘i’ above. All four forms are equivalent.4.1 MatricesIt is easy to define a matrix of values in <strong>Octave</strong>. The size of the matrix is determinedautomatically, so it is not necessary to explicitly state the dimensions. The expressiona = [1, 2; 3, 4]results in the matrixa =[ ] 1 23 4Elements of a matrix may be arbitrary expressions, provided that the dimensions allmake sense when combining the various pieces. For example, given the above matrix, theexpression[ a, a ]produces the matrix

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!