Accessing value in a cell

1 回表示 (過去 30 日間)
jinang patel
jinang patel 2019 年 12 月 1 日
編集済み: Stephan 2019 年 12 月 1 日
Hi,
I am trying to access value of a cell
>> a={'1,65,4,5'}
a =
1×1 cell array
{'1,65,4,5'}
>> a(2)
Index exceeds the number of array elements (1).
>> a{2}
Index exceeds array bounds.
Thanks
Jinang
  3 件のコメント
jinang patel
jinang patel 2019 年 12 月 1 日
Hi Stephen,
expected output - number 65. The problem is that I have data from a file which has a={'1,65,4,5'}, I understand removing the quotes will solve it but I cant change the file that generates the data. It is a single cell, is there a way to convert it to 1x4 array?
Stephan
Stephan 2019 年 12 月 1 日
See my edited answer

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

採用された回答

Stephan
Stephan 2019 年 12 月 1 日
編集済み: Stephan 2019 年 12 月 1 日
Edited because of the comments:
a = {'1,65,4,5'}
b = str2num(a{:})
b(2)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by