How can I calculate the "Median" of floating point numbers
7 次查看(过去 30 天)
显示 更早的评论
I have three two-dimensional arrays containing floating point numbers. I would like to construct a two-dimensional array that contains the "median" or middle value (not the mean) of the three arrays.
For example, if one element of the arrays contained 4.81, 3.54, and 3.56, I'd like to return 3.56, which is the middle value.
How can I do that?
0 个评论
采纳的回答
James Tursa
2023-6-9
E.g.,
x = randi(10,2,3)
y = randi(10,2,3)
z = randi(10,2,3)
xyz = cat(3,x,y,z)
result = median(xyz,3)
6 个评论
James Tursa
2023-6-9
The concatenation is going to take extra time and memory for the temporary data copies, which will slow performance. Could be avoided with a mex routine, but I wouldn't bother with that unless your variables are huge and the performance hit is significant.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!