Appropriate way to store 3d matrix ?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm using
unitcellsize = 1:0.01:1.01;
num = max(size(unitcellsize));
for jj = 1:num
a{jj} = -unitcellsize(jj)/2:0.04:unitcellsize(jj)/2;
b{jj} = -unitcellsize(jj)/2:0.04:unitcellsize(jj)/2;
c{jj} = -unitcellsize(jj)/2:0.04:unitcellsize(jj)/2;
[X{jj},Y{jj},Z{jj}] = meshgrid(a,b,c);
end
Is this an appropriate way to store 3d matrix. I would like to store 3d matrix __x__x__.
If this is the appreciate way, how can I recall 3d matrix for using ?
1 commentaire
Bob Thompson
le 18 Jan 2021
A 3D matrix is created, and data stored, simply by calling out a third dimension:
A = randi(100, 5, 4, 10); % Creates random integer matrix of size 5x4x10
This format works for pretty much any multidimesional matrix generation command (zeros, ones, rand), and assigning specific values just means calling out a third dimensional index value.
A(1,1,1) = 100; % Set first value to 100
A(:,1,1) = 100; % Set first column, first sheet to 100
I'm not sure how this applies to your data though, because all of the variables you've specified seem to just be row matricies, at first glance. Do you have a piece of information you want to assign to every index in a 3D matrix that isn't shown here?
Réponses (0)
Voir également
Catégories
En savoir plus sur Resizing and Reshaping Matrices 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!