循环双谱matlab程序
- function cyclic_bispectrum(x,fs,M1,M2)
- %%% 循环双谱程序
- %%% x 输入的信号
- %%%=====================================================
- %%% 第一步:求信号的三次变换,依据为: y(i,n)=x(i)x(i+n)x(i+n) 后两项n取一样,为方便运算。
- %%%
- M = length(x); % 信号采样点数
- if M>20000
- M = 20000;
- end
- % 初始化
- N1 = fix(3*M/4); N2 = M - N1; % 必须满足 M=N1+N2,且N1>N2。
- y = zeros(N1,N2);
- for i=1:N1
- for n=1:N2
- y(i,n) = x(i)*x(i+n)*x(i+n);
- end
- end
- %%%=====================================================
- %%% 第二步:求信号的三次变换,依据为: Rtk(n)=1/N1*sum(y(i,n)*exp(-1i*2*pi*i*k/N1))
- %%% M1对应 2pi 弧度,分辨率 2pi/M1
- Rtk = zeros(N2,M1);
- for n = 1:N2
- % Rtk(n,:) = 1/N1*fftshift(fft(y(:,n),M1));
- Rtk(n,:) = fft(y(:,n),M1);
- end
- %%%=====================================================
- %%% 第三步:求循环双谱切片谱,依据为: Imk(m)=sum(Rtk(1:N2).*exp(-1i*2*pi*m*(1:N2)/N2))
- %%%
- Imk = zeros(M1,M2);
- for m = 1:M1
- % Imk(m,:) = fftshift(fft(Rtk(:,m),M2));
- Imk(m,:) = fft(Rtk(:,m),M2);
- end
- aaa = Imk(1:M1/2,1:M2/2);
- x_lab = fs/2*linspace(0,1,M1/2);
- y_lab = fs/2*linspace(0,1,M2/2);
- % I_abs = abs(Imk);
- I_abs = abs(aaa);
- %%% 画图
- figure
- mesh(y_lab,x_lab,I_abs)
- % mesh(I_abs)
- % figure
- % plot(x_lab,I_abs(:,1))
- %
- figure
- plot(x_lab,I_abs)
- %
- % figure
- % plot(x_lab,I_abs(:,round(M1/2)-1))
复制代码 |