How to find the middle value of a n array
248 次查看(过去 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 个评论
更多回答(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!