Is it possible to directly take an n_th character of an array, which is located in an array of cells? Example:
>> G = {'1010101', '0010101', '0010101'} % an array of cells with strings in each cells
Now, I would like to access the first string and get the first character (in my case a bit). Till now I would assig a value of the cell to a variable x and then look into the first character, e.g:
x = G{1};
x(1)
Which is kind of annoying. Is it possible to get the character value without reassigning it? Like in Mathematica with double brackets.

 採用された回答

dpb
dpb 2015 年 12 月 27 日

0 投票

>> G = {'1010101', '0010101', '0010101'};
>> G{1}(1)
ans =
1
>>
doc cell % for details on addressing
NB: however,
G{:}(1)
does not work; cellfun comes to the rescue.

1 件のコメント

dpb
dpb 2015 年 12 月 27 日
More detail follows under general data forms for cell arrays...
<Access-data-in-a-cell-array> Follow the links therein as well; the story ain't over 'til its over... :)

サインインしてコメントする。

その他の回答 (1 件)

DenLi
DenLi 2015 年 12 月 28 日
編集済み: DenLi 2015 年 12 月 28 日

0 投票

Thank you! Works perfectly!

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2015 年 12 月 27 日

編集済み:

2015 年 12 月 28 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by