Rearraning an Array of variable size
조회 수: 1 (최근 30일)
이전 댓글 표시
Hello Matlab Comm
I am not a coder but since the corona crisis my thesis was transformed into matlab case. I have the following problem:
I have an array of size x (odd or even size, both occur). Lets make it x==20 for this example. My goal is to re-arrange the order of the lines in the array.
e.g. if
x=20
Array=zeros(x,1)
for k=1:x
Array(k,1) = k;
end
We have Array() look smth like
1
2
3
4
5
...
19
20
I want to rearaange Array() so the order becomes
1
20
10
5
15
3
13
7
17
4
14
...
So, always order of Min, Max, and mid. I hope you get what I mean. I think it is sort of a Binary Tree but I really a, stepping in the dark here. Any help is gratly appreciated!
I am happy to answwer any questions and explain in more detail. Thanks in advance for any help!
Kindly
Willi
댓글 수: 0
채택된 답변
Rhea Chandy
2020년 8월 6일
Hello Wilhelm,
It is my understanding that you are looking to understand how to rearrange an array.
The documentation Reshaping and Rearranging Arrays will help you to understand how to reshape and rearrange arrays in any order. For further information, you can find how to filter the elements of an array by applying conditions to the array, by referring to the documentation Find Array Elements That Meet a Condition.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!