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!