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.

 Risposta accettata

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

2 Commenti

bilhan
bilhan il 18 Mag 2011
thank you mr.bobrov
Jan
Jan il 18 Mag 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{:}).

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by