How to find the middle value of a n array
267 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I have a 3x1 structure called sS, and inside that structure i have 3 arrays (323x2, 292x2 and 231x2) which contains 323, 292 and 231 X,Y coordinates, respectively.
I am trying from each of those three arrays somehow to extract this middle row inside (for eg. first array (323x2) that would be 161-st row which contains X,Y coordinates).
I tried with median but that is not what I need. I need to extract the middle row of all of my 3 arrays and store them in a new variable.
Maybe this seems trivial to someone, but I am having problems with it.
Can anybody help?
Thanks in advance!!
0 件のコメント
採用された回答
Guillaume
2015 年 6 月 1 日
The structure bit is irrelevant. To get the middle row, you could simply do:
m = rand(323, 2); %for demo
midrow = m(ceil(end/2), :)
Not that for matrix with an even number of row, there is no one single middle row. The above will give you the first of the two middle rows.
2 件のコメント
Harish Pulluri
2016 年 5 月 18 日
But in case of even numbers which row it is considered as a middle row
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!