matlab每日练习 lenght函数

matlab每日练习 lenght函数

水平有限,译文中不妥之处恳请指正

length

Length of vector or largest array dimension

向量长度或数组的最大维数

Syntax

函数原型

numberOfElements = length(array)

Description

函数描叙

numberOfElements = length(array) finds the number of elements along the largest dimension of an array. array is an array of any MATLAB data type and any valid dimensions. numberOfElements is a whole number of the MATLAB double class.

For nonempty arrays, numberOfElements is equivalent to max(size(array)). For empty arrays, numberOfElements is zero.

{(译文)numberOfElements = length(array)获取数组最大的维数.数组可以是任意MATLAB数据类型且具备有效的维数.返回值numberOfElements是一个MATLAB双精度类型的整数.

对于一个非空数组,numberOfElements等于函数max(size(array))返回值.对于空的数组,numberOfElements的值为零.}

Examples.

 

实例

Create a 1-by-8 array X and use length to find the number of elements in the second (largest) dimension:

创建一个1乘8的数组X,并调用length获取数组的列数目:

X = [5, 3.4, 72, 28/4, 3.61, 17 94 89];

length(X)
ans =
     8
matlab每日练习 <wbr>lenght函数
 

Create a 4-dimensional array Y in which the third dimension is the largest. Use length to find the number of elements in that dimension:

Y = rand(2, 5, 17, 13);

length(Y)
ans =
    17
matlab每日练习 <wbr>lenght函数
 

Create a struct array S with character and numeric fields of different lengths. Use the structfun function to apply length to each field of S:

S = struct('f1', 'Name:', 'f2', 'Charlie', ...
           'f3', 'DOB:', 'f4', 1917)
S = 
    f1: 'Name:'
    f2: 'Charlie'
    f3: 'DOB:'
    f4: 1917

structfun(@(field)length(field), S)
ans =
     5
     7
     4
     1
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值