convert data from two 3D arrays into three 2D arrays
1 view (last 30 days)
Show older comments
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 Comments
Answers (2)
Sulaymon Eshkabilov
on 13 Jun 2021
Edited: Sulaymon Eshkabilov
on 13 Jun 2021
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
on 13 Jun 2021
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 Comments
See Also
Categories
Find more on Operators and Elementary Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!