Accessing value in a cell

6 Ansichten (letzte 30 Tage)
jinang patel
jinang patel am 1 Dez. 2019
Bearbeitet: Stephan am 1 Dez. 2019
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 Kommentare
jinang patel
jinang patel am 1 Dez. 2019
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 am 1 Dez. 2019
See my edited answer

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephan
Stephan am 1 Dez. 2019
Bearbeitet: Stephan am 1 Dez. 2019
Edited because of the comments:
a = {'1,65,4,5'}
b = str2num(a{:})
b(2)

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by