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

4 views (last 30 days)
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!

Accepted Answer

Jon
Jon on 17 Sep 2019
Edited: Jon on 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

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!