필터 지우기
필터 지우기

How to save multiple 2D arrays in a third dimension in simulink?

조회 수: 12 (최근 30일)
Mariana
Mariana 2020년 4월 26일
답변: Samatha Aleti 2020년 4월 30일
I will be reading multiple 2D arrays of the same size (100, 8) in time. The idea is to concatenate all of them in a 3D array.
How can implement this in simulink?
  댓글 수: 3
madhan ravi
madhan ravi 2020년 4월 27일
Sindars code can be encapsulated in the function block in SIMULINK.
Mariana
Mariana 2020년 4월 29일
I am not sure on how to save them. I have multiple 2D arrays and I would like to save only the arrays that have a 1 in the last column.
I am receiving matrixes that have the same size but witth values non zero and zero. I would like to save into a 3D array all the 2D arrays with no zero values. Each one of them found concatenated into the 3rd dimension.
I am not sure how to implement it.

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

답변 (1개)

Samatha Aleti
Samatha Aleti 2020년 4월 30일
Hi,
You can accordingly place a condition for concatenating each 2D array to a 3D array. Here is a sample code(modified code of Sindar's):
N = 10; % Let Num of 2D arrays
my3Darray=zeros(100,8,N);
for ind=1:10
my2Darray = randi(50,100,8);
my3Darray(:,:,ind) = my2Darray;
% check for "1" in last column and remove concatenation of 2D array if there is no "1"
if all(my2Darray(:,end) ~= 1)
my3Darray(:,:,ind) = [];
end
end

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by