Accessing data in a cell array

조회 수: 2 (최근 30일)
Yongmin
Yongmin 2015년 4월 7일
편집: Jeffrey Girard 2015년 4월 8일
Hello, I have a (1x7) cell array that contains as follows:
cell_array =
Columns 1 through 4
[10000x8 char] [10000x6 char] [10000x6 char] [10000x1 double]
Columns 5 through 7
[10000x64 char] [10000x10 char] [10000x1 int]
I want to access some part of cell_array, i.e. the 100 line of data in cell_array from row 2101 to row 2200. Would you please help me how to refer those elements of cell_array?
Thanks a lot!
  댓글 수: 2
Image Analyst
Image Analyst 2015년 4월 7일
Yongmin
Yongmin 2015년 4월 8일
편집: Yongmin 2015년 4월 8일
Thanks for your advice. However, would you please explain more? As in case of database, I would like to select all columns of some records (rows) only. In case of a cell array, I cannot use the following command:
cell_array(1,1:7){2101:2200,:}
This gives an error, "()-index must appear last in an index expression."
How can I do what I want? Thanks in advance.

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

답변 (1개)

Jeffrey Girard
Jeffrey Girard 2015년 4월 8일
Hopefully this will give you some clues:
c = cell(1,2);
c{1} = ['abcd';'efgh'];
c{2} = [1,2,3,4;5,6,7,8];
c =
[2x4 char] [2x4 double]
string = c{1}(2,2:3)
string =
fg
number = c{2}(1:2,3:4)
number =
3 4
7 8
  댓글 수: 2
Yongmin
Yongmin 2015년 4월 8일
Thanks a lot for your answer.
BTW is there any way to handle strings and numbers together?
I understand from your answer that it is not possible to handle strings and numbers together within a cell.
Please clarify this point. Thank you!
Jeffrey Girard
Jeffrey Girard 2015년 4월 8일
편집: Jeffrey Girard 2015년 4월 8일
MATLAB really wants you to keep strings and numbers separate. Your options are to convert the numbers to strings (e.g., num2str() ) or write them both to cells.

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

카테고리

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