length
最大阵列尺寸的长度
Syntax
Description
Examples
Number of Vector Elements
Find the length of a uniformly spaced vector in the interval[5,10]
.
v = 5:10
v =1×65 6 7 8 9 10
L = length(v)
L = 6
Length of Rectangular Matrix
String Array
创建一个字符串数组并计算其长度,即每行元素的数量。
X = ["a""b"“C”;“ D”“ e”"f"]
X =2x3 string"a" "b" "c" "d" "e" "f"
L = length(X)
L = 3
Length of Structure Fields
Create a structure with fields forDay
和Month
. Use thestructfun
function to applylength
to each field.
S = struct('Day',[1 13 14 26],'Month',{{'扬','Feb','Mar'}})
S =struct with fields:Day: [1 13 14 26] Month: {'Jan' 'Feb' 'Mar'}
l = structFun(@(字段)长度(字段),s)
L =2×14 3
Input Arguments
X
—Input array
scalar|vector|matrix|multidimensional array
Input array, specified as a scalar, vector, matrix, or multidimensional array.
Complex Number Support:Yes
Tips
To find the number of characters in a string or character vector, use the
strlength
function.length
does not operate on tables. To examine the dimensions of a table, use theheight
,width
, orsize
functions.
Extended Capabilities
Tall Arrays
Calculate with arrays that have more rows than fit in memory.
This function fully supports tall arrays. For more information, seeTall Arrays.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
使用GPU CODER™为NVIDIA®GPU生成CUDA®代码。
HDL Code Generation
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.
Thread-Based Environment
Run code in the background using MATLAB®backgroundPool
or accelerate code with Parallel Computing Toolbox™ThreadPool
.
This function fully supports thread-based environments. For more information, seeRun MATLAB Functions in Thread-Based Environment.
GPU Arrays
使用并行计算工具箱™在图形处理单元(GPU)上运行加速代码。
This function fully supports GPU arrays. For more information, seeRun MATLAB Functions on a GPU(Parallel Computing Toolbox).
Distributed Arrays
Partition large arrays across the combined memory of your cluster using Parallel Computing Toolbox™.
This function fully supports distributed arrays. For more information, see运行具有分布式数组的MATLAB功能(Parallel Computing Toolbox).
Apri esempio
如果dispone di una versione modificata di questo esempio. Desideri aprire questo esempio con le tue modifiche?
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- AméricaLatina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- 丹麦(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)