How to split a [30x250x1000] array into 1,000-2D matrices
Afficher commentaires plus anciens
Hello everyone,
I have a dataset of size 30x250x100. I need to feed this array into a function 1,000 times. This is the for loop that I am using for the job. Where data_class will be the 30x250x1000 input array and number_epoch 1000.
Here i am trying to create 1,000 epoch_seg variables. Each one with 30 by 250 matrices given the 1,000 but can't figure out how to update epoch_seg to contain each matrix for every time step.
function epoch = matrix_extractor(data_class,number_epochs)
data_class;
for k=1:number_epochs
epoch(:,:)=data_class(:,:,k);
epoch_seg[k]=epoch(:,:)
end;
end
Thank you!
3 commentaires
madhan ravi
le 10 Fév 2019
Is it okay to store those 3D matrices into a 1 by 1000 cell array?
Stephen23
le 10 Fév 2019
"Here i am trying to create 1,000 epoch_seg variables."
Dynamically creating or accessing variable names is one way that beginners force themselves into writing slow, complex, obfuscated, buggy code that is hard to debug. Read this to know some of the reasons why:
Instead of forcing yourself inrto writing inefficient, complex code, you should just use indexing. Indexing Is neat, simple, and very efficient. Unlike what you are trying to do.
Kevin Brinneman
le 10 Fév 2019
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Import and Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!