MATLAB: Arrange file length matlab

wav

hello everyone
I got some files that has a length 20000 cell and the others are shorter then 20000 . I want to make these short files to complete the set of cell 20000 with replacing the missing with ones or zeros .
and am using this code to read the files
for k = 1:numfiles
myfilenames = sprintf('a%d.wav', k);
[mydata{k}, myfs{k}] = audioread(myfilenames,[1,2000]);
end

Best Answer

Maybe:
for k = 1:numfiles
File = sprintf('a%d.wav', k);
[signal, myfs{k}] = audioread(File);
if size(signal, 1) < 20000 % Pad signal with zeros
signal(20000, :) = 0;
end
mydata{k} = signal;
end
Usually "data" is a sufficient name already, while "mydata" is a tiny overkill - of course these are your data ;-) Especially "myfilenames" is confusing to specify one file.