How to save multiple 2D arrays in a third dimension in simulink?
Mostrar comentarios más antiguos
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 comentarios
I'm not familiar with simulink, but in Matlab:
my3Darray = cat(3,my2Darray1,my2Darray2,<etc.>);
or, while making them:
my3Darray=zeros(100,8,10);
for ind=1:10
my2Darray = rand(100,8); % or however you read them
my3Darray(:,:,ind) = my2Darray;
end
madhan ravi
el 27 de Abr. de 2020
Sindars code can be encapsulated in the function block in SIMULINK.
Mariana
el 29 de Abr. de 2020
Respuestas (1)
Samatha Aleti
el 30 de Abr. de 2020
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
Categorías
Más información sobre Simulink Functions en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!