how to assign cell array to multiple matrix

1 Ansicht (letzte 30 Tage)
Akshay Sahu
Akshay Sahu am 7 Jan. 2020
Kommentiert: Akshay Sahu am 7 Jan. 2020
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 Kommentare
Stephen23
Stephen23 am 7 Jan. 2020
Bearbeitet: Stephen23 am 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.
Akshay Sahu
Akshay Sahu am 7 Jan. 2020
Thank you I understand that accessing the data will be more difficult, so i'll go with cell array

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Bhaskar R
Bhaskar R am 7 Jan. 2020
B = cell2mat(C);

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Produkte


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by