Rearraning an Array of variable size
2 ビュー (過去 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 で Cell Arrays についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!