Merging Arrays in Ascending Order

조회 수: 45 (최근 30일)
Chris Dan
Chris Dan 2019년 12월 20일
댓글: Chris Dan 2020년 1월 10일
Hello, I am new to matlab. I have this problem. I have to merge two or more arrays into a new array in ascending order for example
The size of the new array will be equal to the sum of all the input arrays.
INPUT :
a = [1 2 3 5 6 8 9 ]
b = [4 7 10 15 17 20 ]
c = [11 12 13 14 16 18 19]
OUTPUT:
d = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20]
  댓글 수: 5
Chris Dan
Chris Dan 2019년 12월 26일
I have another problem,
If I am using a struct like this
talha4.JPG
How can I combine them, into 1 arary and then sort them in Ascending order?
BN
BN 2019년 12월 26일
편집: BN 2019년 12월 26일
Oh, this is a different question than the first one. If v is the name of your struct:
C = struct2cell(v)
then you can sort it using
Sort_C = sort(C)

댓글을 달려면 로그인하십시오.

채택된 답변

BN
BN 2019년 12월 21일
Hello my friend, I'm new too.
I guess you can use:
d = [a b c]
then sort:
d_sort = sort (d)
  댓글 수: 3
Chris Dan
Chris Dan 2020년 1월 10일
hey,
I kind of solved it with uniquetal function

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by