want to convert cell to matrix
4 views (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Andrei Bobrov
on 18 May 2011
variant
for j = 1:length(A)
k = num2str(j);
eval(['b' k '=A{' k '}']);
end
or
[b1,b2,b3,...,bN] = A{:};
2 Comments
Jan
on 18 May 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{:}).
More Answers (0)
See Also
Categories
Find more on Matrix Indexing 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!