Unformatted text preview: TLAB doubles include imaginary and complex values 1 To Create a New Variable
Simply assign some value to the variable and MATLAB creates it. Brackets denote matrices. var = 45.8; complex = 0.5 0.5 * i; list = [ 1.0 2.0 3.0 ]; x = 2.0; y = 3.0; Creating Matrices
Matrices are automatically assumed to be in row order separated by commas or spaces. Rows can be separated by semicolons (;) or new lines. a = [1.0, 3.0, 5.0; 2.0, 4.0, 6.0] b = [1.0 3.0 5.0 2.0 4.0 6.0 ] Creating Matrices
The single quote after a matrix definition causes it to transpose v=[0 1 2 3] w=v' Is equivalent to the statement w = [ 0; 1; 2; 3] or w=[ 0 1 2 3] Creating Matrices
The number of elements in every row must be the same and the number of elements in every column must be the same. b = [ 10 15 20; 6 9 ] error! Creating Matrices
An element of a matrix may be referenced using parentheses. Note that, unlike C++, rows and columns in MATLAB are numbered starting at 1. If c has not been previously created c(2, 3) = 5; Is equivalent to the statement c=[ 0 0 0 0 0 5 ]; Creating Matrices
You may also use algebraic operations or references to data in the definition of an array a = [ 0 1+1 1+3*4 ]; b = [ a(2) a(1) a ]; Is equivalent to a = [ 0 2 13 ]; b = [ 2 0 0 2 13 ]; 2 Shortcut Expressions for Matrix Initialization
If you want to create a vector in which the terms are regularly spaced you can use the colon operator. first:increment:last...
View
Full Document
 Spring '07
 JeffRingenberg
 matlab, Multiplication, Ring, Nested function, Array Operations

Click to edit the document details