www.pudn.com > color_noise.rar > color_noise.m
%%Generate color noise
WIT=randn(1000,1) % Gossian noise
GBN1=gbngen(1000,2);
WITF=filter(1,[1 -0.9],WIT); %% Generate color noise by f(q)=1/(q+0.9)
WITF=(WITF-mean(WITF))/std(WITF); %% normalized
GBN1F=filter(1,[1 -0.9],GBN1);
GBN1F=(GBN1F-mean(GBN1F))/std(GBN1F);%normalized
Facwitf=max((WITF.^2))/cov(WITF);
Facgbn1f=max((GBN1F.^2))/cov(GBN1F);
w=[0:127]/127*pi;
witfs=spa(WITF,50,w);
wits=spa(WIT,50,w)
facwit=max((WIT.^2))/cov(WIT);
gbn1s=spa(GBN1,50,w);
gbn1fs=spa(GBN1F,50,w);
facgbn1=max((GBN1.^2))/cov(GBN1)
figure
subplot(211); plot(WITF)
title(['Filtered white Noise, CrestFAC=',num2str(Facwitf)]);
axis([0 1000 -4 4])
xlabel('samples')
subplot(212)
plot(w,witfs.spectrum(:,1:length(w)))
title('spectrum')
figure
subplot(211);plot(WIT);
title([' white Noise, CrestFAC=',num2str(facwit)]);axis([0 1000 -4 4])
subplot(212)
plot(w,wits.spectrum(:,1:length(w)))
title('spectrum')
figure
subplot(211); plot(GBN1F)
title(['Filtered white GBN, CrestFAC=',num2str(Facgbn1f)]);
axis([0 1000 -4 4])
subplot(212);
plot(w,gbn1fs.spectrum(1,1:length(w)));
title('spectrum')
figure
subplot(211); plot(GBN1)
title(['GBN, CrestFAC=',num2str(facgbn1)]);
axis([0 1000 -4 4])
subplot(212);
plot(w,gbn1fs.spectrum(1,1:length(w)));
title('spectrum')