MATLAB Answers

## How to read cell range from one cell in file

Asked by Diana

### Diana (view profile)

on 6 May 2013

Hi all

I want to read cell range from a file. Each cell of this file contains a different cell range. For example raw is the file and raw(2,3) = 3:4, 6:10

So I want X(raw{2,3}) which is the same as X(3:4,6:10) but when I run it they are not the same. Each one gives different result. Any idea how I can fix it?

Iman Ansari

### Iman Ansari (view profile)

on 6 May 2013
```X(raw{2,3})====X([3 4 6 7 8 9 10])
```
```X(3:4,6:10)====X([3,4],[6 7 8 9 10])
```
Diana

### Diana (view profile)

on 6 May 2013

Can you explains to me why raw{2,3} = 3:4,6:10 but X(raw{2,3}==X([3 4 6 7 8 9 10]) ?

## Products

No products are associated with this question.

## 2 Answers

### Andrei Bobrov (view profile)

Answer by Andrei Bobrov

### Andrei Bobrov (view profile)

on 6 May 2013

```raw(2,3) = {3:4, 6:10};
```

Diana

### Diana (view profile)

on 6 May 2013

X(raw{2,3}) is not giving the same result as X(3:4, 6:10).

Andrei Bobrov

### Andrei Bobrov (view profile)

on 6 May 2013
```raw = cell(3);
raw{2,3} = {3:4,6:10};
```
```X = randi(18,10); eg
```
```X(raw{2,3}{:})
```
Diana

### Diana (view profile)

on 13 May 2013

Using this show an error: Cell contents reference from a non-cell array object.

The cell i AM TRYING TO EXPORT CONTAINS CHARACTERS LIKE '3:6, 7:8'

Any idea how I could fix it?

Answer by Yao Li

### Yao Li (view profile)

on 13 May 2013

Try

```raw{2,3}={3:4,6:10};
x=rand(10,10);
x(3:4,6:10)
x(raw{2,3}{1,1},raw{2,3}{1,2})
```

Diana

### Diana (view profile)

on 17 May 2013

Now it is returning:Cell contents reference from a non-cell array object.

#### Join the 15-year community celebration.

Play games and win prizes!

Learn more

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

### MATLAB Academy

New to MATLAB?

Learn MATLAB today!