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

2 vues (au cours des 30 derniers jours)
IM
IM le 17 Sep 2019
Commenté : IM le 17 Sep 2019
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!

Réponse acceptée

Jon
Jon le 17 Sep 2019
Modifié(e) : Jon le 17 Sep 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

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by