'Is there a MATLAB function for reshaping array
I want to reshape two array. For example:
a=[17 21 24 32]
b=[10 15 18]
Thus, I want to get a new array:
c=[10 15 17 18 21 24 32]
How do it? Thank you!
Solution 1:[1]
The MATLAB command you need to arrange the elements is sort.
>> c = sort([a,b])
c =
10 15 17 18 21 24 32
Solution 2:[2]
You can do concatenation or union of arrays based on their length
if length(b)<length(a)
c = [b,a];
else
c = [a,b];
More about union https://www.mathworks.com/help/matlab/ref/double.union.html
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Edric |
| Solution 2 |
