Home > Blockchain >  Is there a MATLAB function for reshaping array
Is there a MATLAB function for reshaping array

Time:04-04

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!

CodePudding user response:

The MATLAB command you need to arrange the elements is sort.

>> c = sort([a,b])
c =
    10    15    17    18    21    24    32

CodePudding user response:

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

  • Related