MATLAB 帮助中心
元胞数组创建、索引
{}
花括号 {} 用于创建元胞数组和对其进行索引,还用于对表和时间表中的数据进行索引。例如,T{rows,vars} 从表或时间表的指定行和变量返回串联数据的数组。
T{rows,vars}
示例
全部展开
使用花括号创建一个包含三个数据元胞的元胞数组,然后对其中一个元胞进行索引。
C = {[2.6 4.7 3.9], rand(8)*6, "myString"}
C=1×3 cell array {[2.6000 4.7000 3.9000]} {8×8 double} {["myString"]}
C{1,3}
ans = "myString"
使用花括号索引访问表中的数据。
创建一个包含三个变量的表,然后对所有变量的第一行数据进行索引。
T = table((1:4)',5*ones(4,1),2*ones(4,1))
T=4×3 table Var1 Var2 Var3 ____ ____ ____ 1 5 2 2 5 2 3 5 2 4 5 2
T{1,:}
ans = 1×3 1 5 2
在 R2006a 之前推出
( ) | [ ]
( )
[ ]
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
欧洲
亚太
联系您当地的办事处