12.07.2015 Views

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

Basics of MATLAB and Beyond

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

1.3 MatricesThe basic object that matlab deals with is a matrix. A matrix is anarray <strong>of</strong> numbers. For example the following are matrices:⎛ ⎞⎛⎞12 3 9⎝ −1200 0 1e6 ⎠ , ( 1 2 3 4 5 ) i, ⎜ −i⎟⎝ i ⎠ , 42.0.1 pi 1/3−iThe size <strong>of</strong> a matrix is the number <strong>of</strong> rows by the number <strong>of</strong> columns.The first matrix is a 3 × 3 matrix. The (2,3)-element is one million—1e6st<strong>and</strong>s for 1 × 10 6 —<strong>and</strong> the (3,2)-element is pi = π =3.14159 ... .The second matrix is a row-vector, the third matrix is a column-vectorcontaining the number i, which is a pre-defined matlab variable equalto the square root <strong>of</strong> −1. The last matrix is a 1 × 1 matrix, also calleda scalar.1.4 VariablesVariables in matlab are named objects that are assigned using theequals sign = . They are limited to 31 characters <strong>and</strong> can containupper <strong>and</strong> lowercase letters, any number <strong>of</strong> ‘_’ characters, <strong>and</strong> numerals.They may not start with a numeral. matlab is case sensitive: A<strong>and</strong> a are different variables. The following are valid matlab variableassignments:a = 1speed = 1500BeamFormerOutput_Type1 = v*Q*v’name = ’John Smith’These are invalid assignments:2for1 = ’yes’first one = 1To assign a variable without getting an echo from matlab end theassignment with a semi-colon ;. Try typing the following:a = 2b = 3;c = a+b;d = c/2;dwhowhosclearwhoc○ 2000 by CRC Press LLC

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

Saved successfully!

Ooh no, something went wrong!