generator_color_noise.m
来自「This program generates a color signal as」· M 代码 · 共 32 行
M
32 行
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% This program generates a color signal as the input signal and a desired signal of the idetification plant %
% on Nov 11,2007 %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [x,d,num]=generator_color_noise(K,snr,N,Fa,Fb);
%[x,d,num]=generator_color_noise(10000,25,512,0.35,0.65);
%----------------------------------------------------%
% Input parameters:
% K : the length of the signal
% N : the order plus 1
% snr : ratio of the input signal to noise signal
% Fa : the low cut-off frequency of the plant
% Fb : the up cut-off frequency of the plant
%----------------------------------------------------%
%---------------initialization-----------------------%
x=randn(1,K); % generate a random signal as input signal
d=zeros(1,K); % define the desired signal
%-----------signal generation------------------------%
num=fir1(N-1,[Fa Fb]); % generate the numerator of the transforing function
den=[1]; % generate the denominator of the transforing function
d=filter(num,den,x); % get the desired signal by filtering the input signal
d=awgn(d,snr); % add the noise signal to the desired ignal
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?