MATLAB Answers

How to seperate a cell?

2 views (last 30 days)
Sams
Sams on 16 May 2014
Edited: Vivek on 16 May 2014
Hi everyone! I've got a cell like this
[ 17x2 double]
[2042x2 double]
[ 7x2 double]
[ 9x2 double]
[ 7x2 double]
[ 3x2 double]
[ 4x2 double]
[ 7x2 double]
[ 2x2 double]
[ 23x2 double]
[ 28x2 double]
now i'd like to seperate each n x m matrix. It should look like this
a1 = [17x2 double]
a2 = [2042x2 double]
...
Does anyone know how to do so? thanks

  0 Comments

Sign in to comment.

Answers (2)

Azzi Abdelmalek
Azzi Abdelmalek on 16 May 2014
If you mean to create several variables, this is not a good idea, look at http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F

  0 Comments

Sign in to comment.


Vivek
Vivek on 16 May 2014
Edited: Vivek on 16 May 2014
for i=1:length(A)
eval(['A',num2str(i),'=A{',num2str(i),'}']);
end
If you are writing a function, then specify the workspace in eval command. You can also use assignin instead of eval

  0 Comments

Sign in to comment.

Sign in to answer this question.