How to store a large arrays into cells?

3 vues (au cours des 30 derniers jours)
Carter Hoffman
Carter Hoffman le 18 Juil 2022
Modifié(e) : Dyuman Joshi le 2 Août 2022
I generate data using a multiplexed data application (6x6 = 36 different conditions, data collected for all at once). I have generated a nice code which takes the entire data file and separates each data point by its condition (1 of 36 possible conditions possible) and would like to arrange the now 36 data files into a single cell array for easy accessing/indexing. I am having trouble (I think) because each individual data file will contain several thousand data points, each with 15 values. In other words, each datafile is a Nx15 matrix.
the conditions in question are 6 antibiotics in 6 different concentrations; this is not super important except to say that the 36 conditions are already arranged in a 6x6 matrix.
for example, say I have antibiotics A, B, C, D, E, F each one in concentrations 1, 2, 3, 4, 5, 6, then the matrix of conditions will be a 6x6:
[ A1 A2...A6
B1 B2...B6
C1 C2...C6
D1 D2...D6
E1 E2...E6
F1 F2...F6 ]
(bearing in mind that each condition, A1 or B6 and so-on will be a Nx15 double, with N different for each of 36 conditions)
If we suppose that i have the example datafiles A1 = 2205 x 15 double, A2 = 2235 x 15 double and A3 = 1807x15 double, I am trying to arrange them into a cell array using a line of code along the lines of:
data{1,1} = A1;
data{1,2} = A2;
data{1,3} = A3;
.......
data{6,6} = F6;
and am receiving the error: "Unable to perform assignment because brace indexing is not supported for variables of this type."
Can someone please help? I am certain that I just have some little syntax wrong but cannot seem to figure it out. As a general reminder, the goal is to generate a single 6x6 cell array, where each cell in the array contains a N x 15 matrix. Thanks in advance,
Carter
  4 commentaires
dpb
dpb le 2 Août 2022
Yes, but more importantly and it only helps if you don't create explicit variables A1, A2, ..., An but they are then instead an array or struct fields or somesuch so that they can be referenced programmatically instead of by explicit reference.
It wasn't clear to me if the references in the initial post were referring to variables or values...I presumed variables since you said each was an Nx15 array.
Dyuman Joshi
Dyuman Joshi le 2 Août 2022
Modifié(e) : Dyuman Joshi le 2 Août 2022
Yes, you can do it that way. Something like this
y=rand(120,90);
for i=1:20:120 %you have to define your i according to your data
for j=1:15:90
data{ceil(i/20),ceil(j/15)}=y(i:i+19,j:j+14);
end
end
data
data = 6×6 cell array
{20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double} {20×15 double}

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by