필터 지우기
필터 지우기

How do I convert a column to numeric?

조회 수: 58 (최근 30일)
jakobjakob
jakobjakob 2018년 6월 6일
댓글: jakobjakob 2018년 6월 6일
See the image
I want to count with the 1st column, but I always get the message "Undefined operator" - "for input arguments or type 'cell'." What can I do about it? I think the column is not numeric, but I am not sure. Who can help me?
  댓글 수: 8
jakobjakob
jakobjakob 2018년 6월 6일
편집: jakobjakob 2018년 6월 6일
I uploaded the variable, its about the variable ndata

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

채택된 답변

Stephen23
Stephen23 2018년 6월 6일
편집: Stephen23 2018년 6월 6일
Where C is your cell array:
V = str2double(C(:,1))
This assumes that there is no header, and that each cell of the first column contains one number stored as a char (using a dot, not comma).
  댓글 수: 9
Stephen23
Stephen23 2018년 6월 6일
편집: Stephen23 2018년 6월 6일
@jakobjakob: The concept for indexing cell arrays is simple:
  • {} curly braces access the data inside the cells.
  • () parentheses access the cells themselves.
Just think of cell arrays like boxes: do you want to pick up the box (the cell, ()), or whatever that is inside the box (the data, {}). Sometimes you want to pick up the box, and sometimes you want to get out whatever is inside... each of these can be useful.
Therefore to access the contents of one cell you just need to use curly braces:
alldata{1,1} - 10
jakobjakob
jakobjakob 2018년 6월 6일
Thanks a lot! Such a simple solution...

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by