简体   繁体   English

Julia中数组的最小维数

[英]Minimum dimension of an array in Julia

Let us consider an array which could be given by AA = [1] or by AA= [1 2]. 让我们考虑一个可以由AA = [1]或AA = [1 2]给出的数组。 Thus, we don't know beforehand its dimensions. 因此,我们事先并不知道它的尺寸。

We can extract the minimum dimension in Matlab using: 我们可以使用以下方法在Matlab中提取最小维数:

min(size(AA))

What commands should I use in Julia? 我应该在Julia中使用哪些命令? A similar approach would lead to an error: 类似的方法会导致错误:

m,n=size(AA,1),size(AA,2)

minimum(m,n)

it seems that Julia computes the minimum of a collection and it would not see (m,n) as a collection. 似乎Julia计算集合的最小值,它不会将(m,n)看作集合。

Doing

minimum(size(A))

just works. 只是工作。

size(A) returns a tuple which is seen as a collection. size(A)返回一个被视为集合的元组。 To get the minimum of several arguments one can use min(m,n) . 要获得几个参数的最小值,可以使用min(m,n)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM