haibaraxx的个人博客分享 http://blog.sciencenet.cn/u/haibaraxx

博文

Matlab: access data in cell array

已有 2168 次阅读 2017-1-6 19:05 |个人分类:Matlab|系统分类:科研笔记| Cell, access, Data, array, curly

There are two ways to refer to the elements of a cell array:

Enclose indices in smooth parentheses, (), to refer to sets of cells—for example, to define a subset of the array;

Enclose indices in curly braces, {}, to refer to the text, numbers, or other data within individual cells.


Curly braces are used in cell array assignment statements.

>>> C={'one', 'two', 'three'; 1, 2, 3};    % C 2X3 cell

C=

   'one'  'two'  'three'

   [  1]    [  2]   [   3]


>>> C(1,2)

ans=

       'two'                                % ans 1X1 cell


>>> C{2,1}

ans=

       1                                  % ans is a number


>>> C{1,2}

ans=

       'two'                              % ans str






https://blog.sciencenet.cn/blog-3031432-1025917.html

上一篇:mac: 小数点由逗号变为点号
下一篇:Matlab: 删除矩阵中含有nan的行列
收藏 IP: 134.1.1.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-6-26 06:51

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部