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

8 ビュー (過去 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 Center および File ExchangeCreating 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