1

I've constructed a simple Matlab cell array:

d1 =
 1
 2
 3
 4
 5

d2 =
 2
 3
 4
 5
 6

d3 =
 3
 4
 5
 6
 7

d = 
[5x1 double]
[5x1 double]
[5x1 double]

clear d1 d2 d3;

How do I access the original array d1 data inside cell array d, after d1 is cleared? If I do:

>> d(1,:)
ans = 
[5x1 double]

but what I want to do is issue this command:

d(what indexing goes here?) 

and have it return:

1 2 3 4 5
Andrey Rubshtein
  • 20,795
  • 11
  • 69
  • 104
ggkmath
  • 4,188
  • 23
  • 72
  • 129
  • 2
    Here's a related question that you may be interested in: [How do concatenation and indexing differ for cells and arrays in MATLAB?](http://stackoverflow.com/questions/2662964/how-do-concatenation-and-indexing-differ-for-cells-and-arrays-in-matlab) – gnovice Oct 15 '10 at 18:17

1 Answers1

5

Nevermind, I figured it out:

d{1,1,:} 

returns back the original d1 information.

ggkmath
  • 4,188
  • 23
  • 72
  • 129
  • 9
    `d{1}` would probably work just as well. `d` is a 1x5 cell array, so `d{n}` is the contents of one of those cells. (`d(n)` is a single cell, aka a 1x1 cell array, not the numeric array you were trying to get.) You can even use multiple subscripts: `d{2}(3)` gets the third element of the array in the second cell. – aschepler Oct 15 '10 at 18:02