How can I divide a signal into blocks?
Afficher commentaires plus anciens
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;
Réponse acceptée
Plus de réponses (1)
Image Analyst
le 11 Déc 2011
What do you want to do with each block? If you want each block to just be a row in a new 2D matrix, simply call
zk = reshape(x, [K, L]);
2 commentaires
Walter Roberson
le 11 Déc 2011
The floor() in the definition of L shows us that he does not expect that x is necessarily an exact multiple of K in length; in that situation, the plain resize() would fail as K*L might not be length(x)
zayed
le 11 Déc 2011
Catégories
En savoir plus sur Signal Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!