convert data from two 3D arrays into three 2D arrays
2 次查看(过去 30 天)
显示 更早的评论
I have two 3D arrays A and B with dimensions n1 x n2 x n3. Indices i = 1:n1, j = 1:n2, k:1:n3 represent values of some variables var1, var2, var3 (for example var1(i) = var1Min + (i-1)*delta_var1).
I would like to convert two given 3d arrays A and B into three 2d arrays var1Array, var2Array, var3Array, with values of the variables var1, var2, var3 and indices representing values in arrays A and B (for example var1Array(i,j), i represents data from A, j represents data from B, i represents Adata = minA + (i-1)*delta_A, j represents data from B, Bdata = minB + (j-1)*delta_B)
Are there any functions to do it automatically in MATLAB? If not, please, give me some hints how to do it.
0 个评论
回答(2 个)
Sulaymon Eshkabilov
2021-6-13
编辑:Sulaymon Eshkabilov
2021-6-13
It is quite simple:
var1Array = A(:,:,1); var2Array = A(:,:,2); var3Array=A(:,:,3);
% OR combining A and B into one array
var1Array = [A(:,:,1);B(:,:,1)] var2Array = [A(:,:,2); B(:,:,2)];var3Array=[A(:,:,3);B(:,:,3)]
...
madhan ravi
2021-6-13
A = rand(2,2,2)
B = rand(2,2,2)
Data = [A; B] % naming variables is a bad idea , keep them concatenated as one 3D matrix, is much simpler than naming each page
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!