NET.createArray
非原生 .NET 类型数组
说明
示例
创建 .NET 泛型类型数组
创建一个 .NET List<Int32>
泛型类型数组。
genType = NET.GenericClass('System.Collections.Generic.List','System.Int32'); arr = NET.createArray(genType,5)
arr = List<System*Int32>[] with properties: Length: 5 LongLength: 5 Rank: 1 SyncRoot: [1x1 System.Collections.Generic.List<System*Int32>[]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
创建并初始化交错数组
创建一个由三个元素组成的 .NET 数组。
jaggedArray = NET.createArray('System.Double[]',3)
jaggedArray = Double[][] with properties Length: 3 LongLength: 3 Rank: 1 SyncRoot: [1x1 System.Double[][]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
为不同维度的数组赋值。
jaggedArray(1) = [1,3,5,7,9]; jaggedArray(2) = [0,2,4,6]; jaggedArray(3) = [11,22];
显示第三个数组的第一个值。
jaggedArray(3,1)
ans = 11
创建交错泛型类型数组
创建一个 List<Double>
泛型类型的交错 数组。
定义泛型类型。
genCls = NET.GenericClass('System.Collections.Generic.List[]','System.Double');
创建数组。
genArr = NET.createArray(genCls,3)
genArr = List<System*Double>[][] with properties: Length: 3 LongLength: 3 Rank: 1 SyncRoot: [1×1 System.Collections.Generic.List<System*Double>[][]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
创建嵌套交错数组
创建一个 System.Double[][][]
类型的交错数组。
netArr = NET.createArray('System.Double[][]',3)
netArr = Double[][][] with properties: Length: 3 LongLength: 3 Rank: 1 SyncRoot: [1x1 System.Double[][][]] IsReadOnly: 0 IsFixedSize: 1 IsSynchronized: 0
输入参数
typeName
— .NET 数组类型名称
字符串 | 字符向量 | NET.GenericClass
完全指定的 .NET 数组类型名称,指定为字符串、字符向量或 NET.GenericClass
对象。
示例: 'System.Double[]'
示例: 'NET.GenericClass('System.Collections.Generic.List','System.Int32')'
m,n,p,...
— 每个维度中的元素数量
整数数组
每个维度中的元素数,指定为整数数组。
版本历史记录
在 R2009a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 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érica Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)