Rearraning an Array of variable size

2 ビュー (過去 30 日間)
Wilhelm Rpprt
Wilhelm Rpprt 2020 年 8 月 3 日
コメント済み: Wilhelm Rpprt 2020 年 8 月 6 日
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

採用された回答

Rhea Chandy
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.
  1 件のコメント
Wilhelm Rpprt
Wilhelm Rpprt 2020 年 8 月 6 日
Hi Rhea
Thanks alot for this help. I will look into those

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by