I can not understand how to fix the code for processing the audio signal

code itself:

clear all x=wavread('signal'); a=xcorr(x); z=abs(fft(a,32000)); w=z(1:500); [f1,f2]=max(w(1:200)); NT=fix((1/f2)*32000) N=length(x); kilkNT=fix(N/NT); NT1=NT-1; n=NT*(1:kilkNT)-NT1; for k=1:kilkNT b(k,:)=x(n(k):n(k)+NT1); end; mx=mean(b); for k=0:kilkNT-1 xcentr((1:NT)+k*NT)=x((1:NT)+k*NT)-mean(x); ΠžΠ¨Π˜Π‘ΠšΠ Π’Π£Π’ (Error using ==> minus, Matrix dimensions must agree.) end; l=1:NT:length(xcentr); for n=0:NT-1 kompstac(n+1,1:length(1))=xcentr(1+n); end; n=size(kompstac,2); for k=1:NT corkomp(k,:)=corPKVP(compstac(k,:)); Π•Π©Π• НЕ УВЕРЕН Π’ ЭВОМ Π Π―Π”ΠšΠ• (Ρ‡Ρ‚ΠΎ Ρ‚ΠΎ с "compstac(k,:)") end; surf(corkomp); shading interp; axis tight; grid on; for k=1:NT Bk(k,:)=abs(fft(corkomp(k,:))); end; surf(Bk); shading interp; axis tight; grid on; m=mean(Bk); plot(m); axis tight; grid on; 

I will be very grateful for the help

    2 answers 2

    Too lazy to understand all the code and the algorithm without comments, the first thing that comes to mind is what is the dimension of Ρ… ?

    As far as I remember, mean gives out not the average across the whole matrix, but only on a row (or a column, I don’t remember exactly - in the last two years I have used matlab three times). for 3Ρ…4 the mean(x) matrix will be 1Ρ…4 in size, and for 3Ρ…4Ρ…5 (in the lab you can create this as well as even more dimensions, only through a cycle), etc. To get a scalar you need to take

     mean(mean(x)) 

      Here, my mistake, I did not look that I downloaded the stereo signal, and the script is designed for mono, but thanks for the time spent anyway)

       Но Ρ‚Π΅ΠΏΠ΅Ρ€ΡŒ, ΠΊΠ°ΠΊ я ΠΈ Π΄ΡƒΠΌΠ°Π», ошибка Ρ‚ΡƒΡ‚: for k=1:NT corkomp(k,:)=corPKVP(kompstac(k,:)); end; % исчислСния коррСляционных ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ сигнала Ошибка: Undefined function or method 'corPKVP' for input arguments of type 'double'. Error in ==> corkomp(k,:)=corPKVP(kompstac(k,:)); 

      help if you can

      If it helps, here are the explanations for the scripts.

       clear all x=wavread('signal'); % Π·Π°Π³Ρ€ΡƒΠ·ΠΊΠ° сигнала a=xcorr(x); % исчислСния ΠΎΡ†Π΅Π½ΠΊΠΈ автокоррСляционной Ρ„ΡƒΠ½ΠΊΡ†ΠΈΠΈ z=abs(fft(a,32000)); % исчислСния ΠΎΡ†Π΅Π½ΠΊΠΈ ΡΠΏΠ΅ΠΊΡ‚Ρ€Π°Π»ΡŒΠ½ΠΎΠΉ плотности мощности w=z(1:500); [f1,f2]=max(w(1:200)); % нахоТдСния максимума Π² низкочастотныС области ΡΠΏΠ΅ΠΊΡ‚Ρ€Π°Π»ΡŒΠ½ΠΎΠΉ плотности мощности сигнала NT=fix((1/f2)*32000) % исчислСния Ρ†Π΅Π»ΠΎΠ³ΠΎ значСния ΠΏΠ΅Ρ€ΠΈΠΎΠ΄Π° коррСлированности N=length(x); kilkNT=fix(N/NT); NT1=NT-1; n=NT*(1:kilkNT)-NT1; for k=1:kilkNT b(k,:)=x(n(k):n(k)+NT1); end; mx=mean(b); for k=0:kilkNT-kilkNT/2 xcentr((1:NT)+k*NT)=x((1:NT)+k*NT)-mean(x); end; % Ρ†Π΅Π½Ρ‚Ρ€ΠΈΡ€ΠΎΠ²Π°Π½ΠΈΠ΅ сигнала l=1:NT:length(xcentr); for n=0:NT-1 kompstac(n+1,1:length(1))=xcentr(1+n); end; % формирования стационарных ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ n=size(kompstac,2); for k=1:NT corkomp(k,:)=corPKVP(compstac(k,:)); end; % исчислСния коррСляционных ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ сигнала surf(corkomp); shading interp; axis tight; grid on; for k=1:NT Bk(k,:)=abs(fft(corkomp(k,:))); end; % исчислСния ΡΠΏΠ΅ΠΊΡ‚Ρ€Π°Π»ΡŒΠ½Ρ‹Ρ… ΠΊΠΎΠΌΠΏΠΎΠ½Π΅Π½Ρ‚ сигнала surf(Bk); shading interp; axis tight; grid on; m=mean(Bk); % исчислСния усрСднСния ΠΏΠΎ Π²Ρ€Π΅ΠΌΠ΅Π½Π½Ρ‹ΠΌ сдвигам plot(m); axis tight; grid on;