how to vectorize this for loop
Mostrar comentarios más antiguos
tic; [s,fs]=audioread('sample.wav'); fdatool
l=length(s); figure('name','speechsignal');
subplot(3,3,1); plot (s); title('speech signal'); xlabel('samples---->'); ylabel('amplitudes---->');
t=(0:1:l-1)/fs; subplot(3,3,2); plot(t,s); title('Speech signal on time axis'); xlabel('time(s) ---->'); ylabel('Amplitude ---->');
f_d=0.1; f_s=floor(l*f_d); overlap=f_s/2; no_f=floor((l/f_s)*2-1); n=zeros(f_s,no_f); n = s( bsxfun(@plus, (1:f_s).', ((1:no_f)-1)*overlap ) );
subplot(3,3,3);
plot(n);
title('Framing');
xlabel('frames');
ylabel('amplitude');
time=toc
% %windowing
w=hamming(f_s);
for i=1:no_f;
xw(:,i)=w.*n(:,i);
end
1 comentario
Respuestas (1)
Jan
el 9 de Ag. de 2017
I assume you can replace the loop
for i=1:no_f;
xw(:,i)=w.*n(:,i);
end
by:
xw = w .* n; % >= R2016b
For older Matlab versions:
xw = bsxfun(@times, w, n);
Categorías
Más información sobre Descriptive Statistics en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!