Discover MakerZone

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

Several errors related to cell arrays

Asked by Mario on 2 Apr 2013

I have this inside a loop:

 Tp=num2cell(Tp);
 T_p{i,1}=Tp;

And just outside that loop, I have:

 T_p=cell2mat(T_p);

That gives me this error:

 ??? Error using ==> cell2mat at 53
 Cannot support cell arrays containing cell arrays or objects.
 Error in ==> Sist_Ecuaciones_valido at 232
 T_p=cell2mat(T_p);

According to an answer I found here, I should use this:

 T_p = cellfun(@cell2mat, T_p, 'UniformOutput', false);
 T_p=cell2mat(T_p);

This gives me this error, though:

 ??? Cell contents assignment to a non-cell array object.
 Error in ==> Sist_Ecuaciones_valido at 193
    T_p{i,1}=Tp;

I've tried to replace the brackets { , } with parenthesis ( , ), but now the errors comes as:

 ??? Cell contents reference from a non-cell array object.
 Error in ==> cell2mat at 37
    if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
 Error in ==> Sist_Ecuaciones_valido at 231
 T_p = cellfun(@cell2mat, T_p, 'UniformOutput', false);

which is the structure I had previously used to solve the first mentioned problem above.

May anyone help me, please? I hope not to bother anyone too much, but I'm running out of time and patience...

Thanks very much, Mario

0 Comments

Mario

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 2 Apr 2013

You do not show your code structure, so I am going to have to guess.

I suspect you have a loop, in which you successfully create the cell array and convert it completely to a matrix with the combination of the two cell2mat() lines. But then I suspect you loop back and try the T_p{i,1} assignment with T_p still in its matrix form instead of being re-initialized to a cell array.

0 Comments

Walter Roberson

Contact us