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!