필터 지우기
필터 지우기

Can't get cell value

조회 수: 2 (최근 30일)
Pedro Felipe Oliveira
Pedro Felipe Oliveira 2015년 8월 28일
댓글: Pedro Felipe Oliveira 2015년 8월 29일
How can I get the 0 of this vector? This way doesn't work :(
>> size(X)
ans =
1 3
>> X{1,1}
ans =
0
-0.0466
-0.0374
-0.0207
>> X{1,1,1}
ans =
0
-0.0466
-0.0374
-0.0207

채택된 답변

Stephen23
Stephen23 2015년 8월 28일
편집: Stephen23 2015년 8월 28일
X{1,1}(1)
  • () parentheses always return the cell or element of the same class.
  • {} curly braces always refer to the cell contents of a cell array.
Which means:
X{1,1} <- extract contents from the cell array X
(1) <- refer to first element of extracted data
The title "Can't get cell value" and your attempts to access this data indicates a misunderstanding of cell arrays. Cell arrays do not have numeric values, they merely contain other arrays. Your data is in a numeric array inside a cell array, so to access any numeric value you need to "remove" the numeric array from the cell array using {}... and it can then be indexed normally using ().
  댓글 수: 1
Pedro Felipe Oliveira
Pedro Felipe Oliveira 2015년 8월 29일
Thanks sir Stephen! It Works!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by