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.

 Accepted Answer

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

2 Comments

thank you mr.bobrov
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{:}).

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!