tags:

views:

48

answers:

1

Hi, 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
+1  A: 

Nevermind, I figured it out:

d{1,1,:} 

returns back the original d1 information.

ggkmath
`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
perfect!!!! thanks aschepler
ggkmath

related questions