How to make from different size matrices one size matrices by adding NaN's?

2 visualizaciones (últimos 30 días)
Hi!
I have a cell array with matrices of different size :
X ={ {6x12x4},{5x12x4}, {10x12x4},{ 6x12x4}, {8x12x4 }}
How can I make all of them in the same size by adding NaNs?
I need as result : X = {10x12x4, 10x12x4, 10x12x4, 10x12x4, 10x12x4 }
Thanks in advance!

Respuesta aceptada

Jon
Jon el 17 de Sept. de 2019
Editada: Jon el 17 de Sept. de 2019
You could do something like this:
X = {rand(6,12,4),rand(5,12,4),rand(6,12,4),rand(8,12,4)}; % generate example data
for k = 1:length(X)
m = size(X{k},1);
X{k}(m+1:10,:,:) = NaN
end

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by