MATLAB: How to divide a signal into blocks

algorithmsignal

I have a noise signal and I want -for some integer K- to break the signal into blocks of K samples, such that the first N samples make up the first block, the next K samples make up the second block, and so on,as below.I want to know if this algorithm correct or not :
x = radar_noise; % input signal
K = 1000; % K CAPITAL is Block Size
L = length(x) - mod(length(x),K); % only full blocks
zk = reshape(x(1:L), K, []);
%M=zeros(K,K); % M ZEROS covariance matrix L*L
M=[];
for i=1:size(zk,1) % LOOP covariance matrix calculation
Mz=zk(i,:)*zk(i,:)'; %
M=M+Mz;
end
M=M/K;

Best Answer

x = radar_noise; % input signal
K = 1000; % K CAPITAL is Block Size
L = length(x) - mod(length(x),K); % only full blocks
zk = reshape(x(1:L), K, []);
This will create zk with each block going down a columns, as you have in your existing code.
It appears to me that in your existing code, once calculate K and L, you then immediately use them with their opposite purposes, using K as if it the number of blocks and using L as if it is a block size.