PRACTICE
VECTOR WITH SPECIFIC VALUES
- Vector with specific values:
COLON OPERATOR = VECTOR:RANGE
- COLON OPERATOR to create a vector from a range of values:
- COLON OPERATOR adjusting spacing:
- COLON OPERATOR decreasing:
LINSPACE (lower limit, upper limit, total number of elements)
CALLING ELEMENTS IN A VECTOR(r)
- calling a single element in a vector:
- calling multiple elements in a vector given a range:
ZEROS()
- filling a vector with zeros
- creating square zeros
TRANSPOSING VECTORS ‘
- transposing a row vector into a column vector and vice versa:
MATRIX(r,c)
- Accessing specific row and column:
INPUTTING VECTORS
- Prompting the user to input an entire vector
OUTPUTTING VECTORS
- disp(m)
- fprintf(’%d\n’,vec1)
- fprintf(’%d ‘,vec1)
THEORY
MATLAB’s indexes vectors starts with index 1
MATLAB AUTOMATICALLY EXTENDING
When you create a vector
v = [1 2 3 4 5]
v =
1 2 3 4 5
and when you input a value into an element passed the initially set number of elements.
The elements in between the previous last element and the new element are automatically set to 0
v(7) = 7
v =
1 2 3 4 5 0 7