## Cell contents assignment to a non-cell array object.

on 27 Apr 2013

### per isakson (view profile)

Hello everybody, I know that this error must be very common, but I have been trying to solve it for two days and I still can´t find the solution, I will try to explain it as fast as I can:

well at first, I had this error:

```In an assignment  A(I) = B, the number of elements in B and
I must be the same.
```
```Error in ==> compic at 34
```

So, I was investigating it and I concluded that probably I was joining a scalar with a vector (It happened to me before), so I changed brackets () to {}, as follows:

```picad{i}= picaduradm(hb,vut,70,kr,dimens(11,i),dimens(11,i+3),dimens(2,i),dimens(2,i+3));
```

And now I get this error:

```Cell contents assignment to a non-cell array object.
```
```Error in ==> compic at 34
```

If you need it, here you have the code of the function picaduradm:

```function picadm = picaduradm(hb,h,revs,kr, dprim1, dprim2,z1,z2)%devuelve el esfuerzo admisible a picadura
```
```ct=1;%factor de temperatura(no se esperan temperatures superiores a los 120ºC)
sc= ((hb*349)+34300)*0.006894759086775369;
N = revs*h*60;
if N<=10^4
cl=1.5;
elseif N>10^4 && N<=10^5
cl=1.3;
elseif N>10^5 && N<=10^6
kl=1.1;
else
cl=1;
end
```
```if dprim1>dprim2 %este bucle comprueba si elengranaje comprobado es el más grande de la pareja para el calculo del ch.
m=z1/z2;
ch=1+(0.00069*(m-1));
else
ch=1;
end
```
```picadm = (sc*cl*ch)/(ct*kr);
```

Thanks you very much.

## Products

No products are associated with this question.

### per isakson (view profile)

on 27 Apr 2013
Edited by per isakson

### per isakson (view profile)

on 27 Apr 2013

I assume

• picad is defined as a vector of doubles

2. The class of picad cannot be changed by an assignment to one of its elements, e.g to picad(i)

You need to have a look at "Getting started, Quick start" in the on-line help. Try to understand my examples below.

```    %%
A   = nan( 1, 4 );
B   = rand( 1, 12 );
ix  = 3;
A( ix ) = B;
%%
A{ ix }
%%
A{ ix } = B;```

and the result (in red) in the command window

```    In an assignment  A(I) = B, the number of elements in B and I must be the same.
Cell contents reference from a non-cell array object.
Cell contents assignment to a non-cell array object.
>> ```

However, defining new variables by assignments is ok

```    >> C = B
C =
Columns 1 through 10
0.9572    0.4854    0.8003    0.1419    0.4218    0.9157    <snip>
Columns 11 through 12
0.8491    0.9340
>> D{3} = B
D =
[]    []    [1x12 double]
>> ```

and

```    >> E(2,:)=B
E =
Columns 1 through 10
0         0         0         0         0         0   <snip>
0.9572    0.4854    0.8003    0.1419    0.4218    0.9157   <snip>
Columns 11 through 12
0         0
0.8491    0.9340```

.

Second thought:

Valid Combinations of Unlike Classes

Jaime

### Jaime (view profile)

on 27 Apr 2013

mmmm picaduradm returns a double (I suppose we can define it like 1 cell vector), but I did not define picad in the code: maybe that is the reason? I don´t have too much experience working with matlab, that´s the main problem. So what would you recomend me to do in this example?

### Jaime (view profile)

on 27 Apr 2013

well, finally I solved it as follows:

```picad(i)= str2double(picaduradm(hb,vut,70,kr,dimens(11,i),dimens(11,i+3),dimens(2,i),dimens(2,i+3)));
```

I must say, that I reached that conclusion after studying the examples isakson gave to me. Thanks you very much!