【发布时间】:2012-06-29 08:12:53
【问题描述】:
我正在尝试找到一个 2d 数组,它表示 3d 数组中第 3 维的最小值。例如
a = floor(rand(10,10,3).*100); % representative structure
b = min(a,[],3); % this finds the minimum but also includes 0
我尝试使用:
min(a(a>0),3)
但这不正确吗?我想我可以对 a 的第三维进行排序,然后在 1:depth-1 内找到最小值 - 但这似乎不是最有效的方法?
有什么想法吗?
【问题讨论】:
-
请注意,如果您排序,最小值是第二个(如果 matlab 索引从 0 开始,则索引 1)元素,您不必再找到
1:depth-1的最小值。但是,是的,这仍然是低效的,必须有更好的方法。 -
应该是
min(a,[],3),否则取a和3中较小的一个 -
感谢您指出 Jonas 的错字,我现在已经更正了。
标签: matlab multidimensional-array