那些
创建所有阵列
描述
x =那些
返回标量1
。
x =
returns anSZ1,,,,。。。,,,,SZN
)SZ1
-by -....- by-SZN
一系列SZ1,,,,。。。,,,,SZN
表示每个维度的大小。例如,一个(2,3)
returns a 2-by-3 array of ones.
例子
正方形阵列
3-D阵列
Size Defined by Existing Array
Define a 3-by-2 array一个
。
a = [1 4;2 5;3 6];sz = size(a)
sz =1×23 2
创建与大小相同的数组一个
X =一个(SZ)
x =3×2111111
Nondefault Numeric Data Type
创建一个1 x-3向量的矢量,其元素是16位未签名的整数。
x =1,,,,3,'uint16'),
x =1x3 UINT16行矢量111
class(X)
ans ='uint16'
Complex One
创建标量1
that is not real valued, but instead is complex like an existing array.
Define a complex vector.
p= [1+2i 3i];
创建标量1
那很复杂p
。
x ='喜欢',p)
x =1。0000+ 0.0000i
大小和数字数据类型由现有数组定义
定义8位未签名整数的2 x-3阵列。
p = uint8([1 3 5; 2 4 6]);
创建与大小和数据类型相同的数组p
。
x =一个(size(p),'喜欢',p),,,,
x =2x3 uint8 matrix111111
class(X)
ans ='uint8'
输入参数
n
-方形矩阵的大小
integer value
方阵的大小,指定为一个整数瓦尔ue, defines the output as a square, n-by-n matrix of ones.
如果
n
是0
, 然后X
是一个空矩阵。如果
n
是negative, then it is treated as0
。
数据类型:双倍的
|单身的
|int8
|int16
|int32
|INT64
|UINT8
|uint16
|UINT32
|Uint64
SZ1,,,,。。。,,,,SZN
-每个维度的大小
两个或多个整数值
每个维度的大小,,,,specified as two or more integer values, definesX
作为a sz1-by...-by-szN array.
如果任何维度的大小为
0
, 然后X
是一个空数组。如果任何维度的大小为负,则将其视为
0
。如果有任何尾随的尺寸大于
2
大小1
, 然后the output,X
,,,,does not include those dimensions.
数据类型:双倍的
|单身的
|int8
|int16
|int32
|INT64
|UINT8
|uint16
|UINT32
|Uint64
SZ
-Output size
整数矢量的整数值
Output size, specified as a row vector of integer values. Each element of this vector indicates the size of the corresponding dimension.
如果任何维度的大小为
0
, 然后X
是一个空数组。如果任何维度的大小为负,则将其视为
0
。如果有任何尾随的尺寸大于
2
大小1
, 然后the output,X
,,,,does not include those dimensions.
Example:sz =[2 3 4]
定义X
作为2 x-3 x-4阵列。
数据类型:双倍的
|单身的
|int8
|int16
|int32
|INT64
|UINT8
|uint16
|UINT32
|Uint64
typename
-Output class
'双倍的'
(默认)|'单身的'
|“逻辑”
|'int8'
|'uint8'
|...
输出类,指定为'双倍的'
,,,,'单身的'
,,,,“逻辑”
,,,,'int8'
,,,,'uint8'
,,,,'int16'
,,,,'uint16'
,,,,'int32'
,,,,'uint32'
,,,,'int64'
, 或者'uint64'
。
p
-原型
variable
原型,指定为变量。
数据类型:双倍的
|单身的
|逻辑
|int8
|int16
|int32
|INT64
|UINT8
|uint16
|UINT32
|Uint64
复杂的数字支持:万博1manbetx是的
扩展功能
C/C ++代码生成
Generate C and C++ code using MATLAB® Coder™.
用法注释和限制:
尺寸必须是真实的,非负整数。
GPU代码生成
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
用法注释和限制:
尺寸必须是真实的,非负整数。
HDL代码生成
Generate Verilog and VHDL code for FPGA and ASIC designs using HDL Coder™.
尺寸必须是真实的,非负整数。
基于线程的环境
使用MATLAB®在后台运行代码backgroundPool
或使用并行计算工具箱加速代码™螺纹池
。
此功能完全支持基于线程的环境。万博1manbetx有关更多信息,请参阅在基于线程的环境中运行MATLAB功能。
GPU数组
一个ccelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.
用法注释和限制:
您可以指定
typename
作为'gpuArray'
。如果you specifytypename
作为'gpuArray'
,数组的默认基础类型为双倍的
。创建具有基础类型的GPU数组
datatype
,将基础类型指定为其他参数typename
。例如,x =一个(3,数据类型,'gpuarray')
creates a 3-by-3 GPU array of ones with underlying typedatatype
。您可以指定基础类型
datatype
作为这些选择之一:'双倍的'
'单身的'
“逻辑”
'int8'
'uint8'
'int16'
'uint16'
'int32'
'uint32'
'int64'
'uint64'
You can also specify the numeric variable
p
作为agpuarray
。如果you specify
p
作为agpuarray
,,,,the underlying type of the returned array is the same asp
。
有关更多信息,请参阅在GPU上运行MATLAB功能(并行计算工具箱)。
分布式阵列
使用Parallel Computing Toolbox™,将群集组合内存的组合存储器划分。
用法注释和限制:
您可以指定
typename
作为'codistributed'
or'分散式'
。如果you specifytypename
作为'codistributed'
or'分散式'
,返回数组的默认基础类型为双倍的
。To create a distributed or codistributed array with underlying type
datatype
,将基础类型指定为其他参数typename
。例如,x =3,datatype,'distributed')
创建一个具有基础类型的3乘3分布矩阵datatype
。您可以指定基础类型
datatype
作为这些选择之一:'双倍的'
'单身的'
“逻辑”
'int8'
'uint8'
'int16'
'uint16'
'int32'
'uint32'
'int64'
'uint64'
You can also specify
p
作为acodistibed
or分散式
大批。如果you specify
p
作为acodistibed
or分散式
数组,返回数组的基础类型与p
。For additional
codistibed
语法,请参阅一个(编码)
(并行计算工具箱)。
有关更多信息,请参阅Run MATLAB Functions with Distributed Arrays(并行计算工具箱)。
版本历史记录
matlab命令
您单击了与此MATLAB命令相对应的链接:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
美洲
- 一个mérica Latina(Español)
- 加拿大(英语)
- 美国(英语)