Organizing 2D matrices of unequal column length into single 3D array

조회 수: 2 (최근 30일)
Rab Nawaz
Rab Nawaz 2022년 10월 28일
이동: Adam Danz 2022년 10월 31일
Hey !
I am trying to arrange my 2D matrix data of unequal coulumn length as a 3D array. I can do it for equal length matrices but requires help for unequal matrices. I used the following code for equal lengths but can anyone help in modifying this code for arranging 2D matrices of unequal length into 3D array. The empty elements may taken as NaN.
% Let Num of 2D arrays
my3Darray=zeros(20,6,x);
for ind=1:x
V=randi(10,20,3);
I=randi(10,20,3);
my2Darray = [I,V];
my3Darray(:,:,ind) = my2Darray;
end
  댓글 수: 5
Rab Nawaz
Rab Nawaz 2022년 10월 31일
@Adam Danz, great ! exactly I was looking for this information and it will work for me.
Rab Nawaz
Rab Nawaz 2022년 10월 31일
@DGM, thanks for your comments. Infact, I will generate faults in power transmission lines for fault classification study and format the data in form of matrix. The number of rows will be according to duration of faults that I will generate. Fortunately, the answer of @Adam Danz will help me to arrage the data of variable size.

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2022년 10월 28일
이동: Adam Danz 2022년 10월 31일
Use padarray to pad your matricies to a standard size. Then you can concatenate them using cat.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by