Creating a multi-dimensional array out of many lower-dimensional arrays
Afficher commentaires plus anciens
Hello!
I currently have a hundred or so large datasets that are MxN (thus 2-D), for the external program that I use to gather this information I must run it for each of the parameters that I'm changing, for example
... etc. Therefore I now have hundreds of MxN datasets that need to be combined into a multi-dimensional array. To give an example:
What I currently have:
data(alpha,mach) = 15; % element of the data at specified alpha and mach, for delta1 = 0; delta2 = 0; delta3 = 0; delta4 = 0;...
data(alpha,mach) = 10; % element of the data at specified alpha and mach, for delta1 = 5; delta2 = 0; delta3 = 0; delta4 = 0;...
Now I would like to have
data(alpha,mach,0,0,0,0,...) = 15;
data(alpha,mach,5,0,0,0,...) = 10;
I've looked into the "cat" command, but I'm not 100% on how it works, and how to check that the data that I've combined retains the same information.
Any help would be greatly appreciated!
9 commentaires
Based on your small example this would not be an efficient use of memory: your proposed array would have many zeros inbetween the actual values that you store. A table might be more suitable for that data:
Another approach is to create vectors of the delta values (so that these do not need to be contiguous) and create a numeric array for the data where the indices of the delta vectors correspond to the same indices in the data array. That would likely be a much more efficient use of memory.
Ayden Clay
le 3 Avr 2020
Ayden Clay
le 4 Avr 2020
Modifié(e) : Ayden Clay
le 4 Avr 2020
Matt J
le 4 Avr 2020
And in what form do you have the data (to be concatenated) now?
Ayden Clay
le 4 Avr 2020
Modifié(e) : Ayden Clay
le 4 Avr 2020
Matt J
le 4 Avr 2020
I'm sorry, but your Maltlab syntax looks entirely made-up, making it hard to understand how your data is held. For example "data.6" is not a name that Matlab would allow you to give to any variable type. My suggestion would be that you re-write the code that created your data so that as it loops through the different delta combinations, it stores results to an N-D array directly. That's what you will want to do anyway for future runs.
Ayden Clay
le 4 Avr 2020
Taiwo Bamigboye
le 4 Avr 2020
Have tried so hard to learn MATLAB on my own but it seems not working for me. Please is there anyone that knows it very well and ready to teach me via zoom or team view, off course am ready to pay. All this online learning is not intuitive for me.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Matrix Indexing 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!