10-05-2012, 11:07 AM
MATLAB Basics
Matlab Basics.ppt (Size: 428 KB / Downloads: 451)
Arrays
The fundamental unit of data in MATLAB
Scalars are also treated as arrays by MATLAB (1 row and 1 column).
Row and column indices of an array start from 1.
Arrays can be classified as vectors and matrices.
Variables
A region of memory containing an array, which is known by a user-specified name.
Contents can be used or modified at any time.
Variable names must begin with a letter, followed by any combination of letters, numbers and the underscore (_) character. Only the first 31 characters are significant.
The MATLAB language is Case Sensitive. NAME, name and Name are all different variables.
Common types of MATLAB variables
double: 64-bit double-precision floating-point numbers
They can hold real, imaginary or complex numbers in the range from ±10-308 to ±10308 with 15 or 16 decimal digits.
>> var = 1 + i ;
char: 16-bit values, each representing a single character
The char arrays are used to hold character strings.
>> comment = ‘This is a character string’ ;
Initializing Variables in Assignment Statements
Arrays are constructed using brackets and semicolons. All of the elements of an array are listed in row order.
The values in each row are listed from left to right and they are separated by blank spaces or commas.
The rows are separated by semicolons or new lines.
The number of elements in every row of an array must be the same.
The expressions used to initialize arrays can include algebraic operations and all or portions of previously defined arrays.