MATLAB: How to store values in matrix without zeros

tonality code

Hello all,
I tried a code for tonality.Here, the signal is divided into frames and for each frame interval I got a tonality value. I did everything right. But when I try to store the values into a matrix (or say into vectors), it takes 0 for unassigned intervals. I dont want those 0 zeros to be present in my vectors as it shows errors in the output.
function [frameval] =
tonalframes(x);
fs = 48000;
frame_duration = 0.1;
frame_len = frame_duration * fs;
N = length(x);
%numFrames = floor((N-1/frame_len)-1);
for t = 1:frame_len:N
frame = x(t: t + (frame_len-1));
frameval(1:frame_len:N,:) =
tonality(frame);
end
%plot(frameval);
end

Best Answer

Consider your matrix is A. Then,
A=A(A~=0)