11 Concatenate vectors
In MATLAB, a programmer can join two (or more) arrays to form a new single array using an operation called concatenation.
Given two row vectors u and v the programmer can create a new row vector w containing all of the elements of u followed by all of the elements of v by writing:
w = [u v];
Given two column vectors u and v the programmer can create a new column vector w containing all of the elements of u followed by all of the elements of v by writing:
w = [u; v];
Create a new script and save it as q6.m. To the newly created script, add some MATLAB statements that perform the following steps in order:
- Creates a \(1 \times 10\) vector of all zeros named
u. Use the functionzerosto create the vector. - Creates a \(1 \times 10\) vector of all ones named
v. Use the functiononesto create the vector. - Creates a row vector
wformed by concatenatinguwithv - Creates a \(8 \times 1\) vector of all ones named
a. Use the functiononesto create the vector. - Creates a \(8 \times 1\) vector of all zeros named
b. Use the functionzerosto create the vector. - Creates a column vector
cformed by concatenatingawithb