MATLAB® is particularly convenient at calculating with lists of numbers. In fact, it was built for manipulating two-dimensional lists called matrices. An n-by-m matrix has n rows and m columns of numbers, and many MATLAB commands know how to work correctly and efficiently with them.
For example, if we have 10 grocery items whose price we would like to add up, we can write
>> sum([2.35 3.45 10.55 12.32 1.99 5.43 2.66 3.78 10.21])
ans =
52.7400
Here we used a function sum and its argument was a (row) vector we created "manually". Other vectors have shorthand notation (try them out with various numbers):
zeros(n,m) (n and m must be positive integers)ones(n,m) (same)n:m (m must be greater than n)s: n:s:m (m might not be the last element of the list)[3 ; 2; 6 ; 7] (notice the semicolons)(n:m)'Do the following practice exercises:
[4:0.1:5], [5:-2:-5].