1

I have x and x is a <1x106 cell> now if I do size(x,1) I get 1 and size(x,2) I get 106. Now what I need to grab the column size for after this is x(1,106) which is a <1x1 cell> but when I open this it's actually a {1x3503 cell} however size(x(1,106),2) returns 1. I figured it would be a simple case of choosing the the row and column inside x but woe is me!

Please don't laugh at me I know this mustn't be difficult and make me look a little like a muppet but until 4 days ago I never even used MATLAB so...

Thanks for bearing with me!
Cheers!

1
  • use {} for indexing cell elements, not () which creates another cell with the index. Commented Apr 17, 2012 at 21:11

1 Answer 1

2

There is a difference between indexing the cells, or indexing the contents of the cells.

For the former, you use parentheses. So x(1,106) is just another cell array that contains the single cell stored in location (1,106) of x. It is not equal to the array that was stored into that cell of x... it's just a singleton cell array made up of that cell from x.

If instead you want to get the contents of that cell, then you use curly braces to do the indexing: some_array = x{1,106}.

Now, some_array will actually be the array that was stored in the (1,106) cell of x.

To highlight it another way, you could alternatively set some_cell_array = x(1,106) and then set contents_array = some_cell_array{1,1}, and then contents_array will actually be the array stored in that cell.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.