how to assign cell array to multiple matrix

If I have
C= 103x1 cell and each cell is 100x3
and I want to store this cell data in matrix using loops
such that B1=C{1}
B2=C{2}
and so on.
for i=1:size(C,1)
B(i)=C{i};
end
I am using this but it's showing indices on left side are not compatible with the size of right side.

3 Comments

Don't create numbered variables. You will regret it. It is much easier to have a cell array, or a normal array. Do you want a 103x100x3 array instead?
Stephen23
Stephen23 on 7 Jan 2020
Edited: Stephen23 on 7 Jan 2020
"...such that B1=C{1} B2=C{2} and so on"
Is there a particular reason why you cannot just use indexing to access the data?
Putting numbers into variable names is a sign that you are doing something wrong. Accessing variable names dynamically is a sign that you are doing something very wrong: it forces you into writing slow, complex, obfuscated, buggy code that is hard to debug. Read this to know why:
Indexing is simple, neat, easy to debug, and very efficient. Unlike what you are trying to do.
Thank you I understand that accessing the data will be more difficult, so i'll go with cell array

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Release

R2014a

Asked:

on 7 Jan 2020

Commented:

on 7 Jan 2020

Community Treasure Hunt

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

Start Hunting!