MatlabIntro
From CCRMA Wiki
Basics
- Use semi-colon at the end of the line to prevent the output of the operation to be printed to the screen
>> x = 1 x = 1
vs.
>> x = 1; >>
Vector and Matrices
- Use square brackets to define a vector/matrix
x = [1 2 3 4 5]
- Inside a vector/matrix definition, commas or spaces separate elements row-wise
>> x = [1 2 3 4 5]
is the same as:
>> x = [1,2,3,4,5]
and they both generate a row vector. Semi-colons, instead, separate elements column-wise:
>> x = [1;2;3;4;5]
General tips
- Try to vectorize every operation if you can