如何找到在矩阵的单元阵列的最大各个维度的? [英] How do I find the maximum of each dimension in a cell array of matrices?

查看:183
本文介绍了如何找到在矩阵的单元阵列的最大各个维度的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我给一个单元阵列 A 它由不同大小的矩阵。例如,我可以有一个三元素单元阵列,其中每个元素的尺寸是:

I am given a cell array A which consists of matrices of different sizes. For example, I could have a three element cell array where the dimensions for each element are:

A{1} -> 4 x 3
A{2} -> 16 x 4
A{3} -> 5 x 14

我将如何通过单元阵列遍历并返回最大值的每个维度整体?例如,该操作的预期输出 A 上面的例子应该给:

How would I traverse through the cell array and return the maximum for each dimension overall? For example, the expected output of this operation with the example A above should give:

[16 14]

这是因为通过检查第一尺寸,行过三个矩阵的最大数目是16,同样地,列在三个矩阵的最大数量是14。

This is because by examining the first dimension, the maximum number of rows over the three matrices is 16. Similarly, the maximum number of columns over the three matrices is 14.

推荐答案

我原来的答复返回电池的最大元素。现在,包括您的评论的权利code:

My original answer returned the maximum element of the cell. Now including your comments the right code:

knedlsepp基本上得到了它。在性能上小规模的改善:

knedlsepp basically got it. Minor improvement in performance:

[a(:,1),a(:,2)]=cellfun(@size,A);
max(a)

这篇关于如何找到在矩阵的单元阵列的最大各个维度的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆