How to skip over zero values in an array?
Show older comments
In an array of audio samples, I would like to copy non-zero samples to a different array, and skip over any zero samples. I have tried using a loop to traverse the array, but I am having issues with bounds.
arrayout = [];
% arraycount = 1;
dim = size(dialsound); % number of samples in audio sample I am using
c = 1;
while (c < dim(1,2))
while(dialsound(1,c) == 0)
c = c + 1;
end
arrayout(1,c) = dialsound(1,c);
c = c + 1;
end
Accepted Answer
More Answers (1)
Matt J
on 15 Nov 2017
Is this what you want
arrayout=nonzeros(dialsound)
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!