If I have an array A = [1 2 3 4 5 6 7 8 9], is there any Matlab command that transforms that array to A = [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9]?
Or do I need to use algorithms for this?
If I have an array A = [1 2 3 4 5 6 7 8 9], is there any Matlab command that transforms that array to A = [1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9]?
Or do I need to use algorithms for this?
On
See the documentation for the reshape function. Here is how you can use it:
First, make a $2$-by-$n$ matrix which has both rows equal to $A$ with:
[A;A]
Then use the reshape function to "flatten" this matrix:
reshape([A;A], 1, [])
The output will be what your are looking for.
Here is the answer.
$$A = [A;A](:)$$
Easy!