Accessing value in a cell

조회 수: 4 (최근 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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by