Appropriate way to store 3d matrix ?

23 次查看(过去 30 天)
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 个评论
Bob Thompson
Bob Thompson 2021-1-18
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?

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by