want to convert cell to matrix

see i have a cell A={[1 2] [3 4] [5 6]..........} i want the output as b1=[1 2] b2=[3 4] b3=[5 6] .......... i want the content of the each element in the cell to be represeted as different matrices.

 Réponse acceptée

Andrei Bobrov
Andrei Bobrov le 18 Mai 2011

0 votes

variant
for j = 1:length(A)
k = num2str(j);
eval(['b' k '=A{' k '}']);
end
or
[b1,b2,b3,...,bN] = A{:};

2 commentaires

bilhan
bilhan le 18 Mai 2011
thank you mr.bobrov
Jan
Jan le 18 Mai 2011
I strongly recommend the non-EVAL method.
But see: http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F It is usually *much* more efficient to use one array and indexing instead of a pile of variables. Therefore I suggest using CELL2MAT, or cat(2, A{:}).

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by