
求大神给我解释一下这个MATLAB源程序的每一行是啥意思
%创建一个原始信号t=[0:0.001:1];sub_t=100;signal=cos(2*pi*50*t);%+2*sin(2*pi*120*t);figure;sub...
%创建一个原始信号
t = [0:0.001:1];
sub_t = 100;
signal=cos(2*pi*50*t);%+2*sin(2*pi*120*t);
figure;
subplot(2,1,1);
plot(t(1:sub_t),signal(1:sub_t),'g'),title('信号'),xlabel('时间(s)');
%给信号增加噪音
randn('state',0);
sign_and_noise = signal + 0.5*randn(size(t));
hold on;subplot(2,1,1);
plot(t(1:sub_t),sign_and_noise(1:sub_t),'b');
legend('原始','干扰后');
%原始信号的频率
N=2048;
SIG= abs(fft(signal,N));
SIG = fftshift(SIG);
F = [-N/2:N/2-1]/N;
figure;
subplot(3,1,1);
plot(F,SIG),title('原始信号的频率');
xlabel('频率');ylabel('振幅(dB)');
SIG_NOISE= abs(fft(sign_and_noise,N));
SIG_NOISE = fftshift(SIG_NOISE);
subplot(3,1,2);
plot(F,SIG_NOISE);title('被干扰信号的频率');
xlabel('频率');ylabel('振幅(dB)');
%创建一个理想的低通滤波器
f = [0:length(t)-1]/length(t);
low_pass = rectpuls(f, 0.15);
subplot(3,1,3);
plot(f, low_pass);title('低通滤波器');
xlabel('频率');ylabel('振幅(dB)');
%频率领域卷积
res_freq = fft(sign_and_noise) .* (low_pass);
res_time = real(ifft(res_freq));
figure(1);
subplot(2,1,2);
plot(t(1:sub_t), res_time(1:sub_t),'r'),title('重建的信号');xlabel('时间(s)');
subplot(2,1,2);
plot(t(1:sub_t), signal(1:sub_t),'b-.');
legend('复原后'); 展开
t = [0:0.001:1];
sub_t = 100;
signal=cos(2*pi*50*t);%+2*sin(2*pi*120*t);
figure;
subplot(2,1,1);
plot(t(1:sub_t),signal(1:sub_t),'g'),title('信号'),xlabel('时间(s)');
%给信号增加噪音
randn('state',0);
sign_and_noise = signal + 0.5*randn(size(t));
hold on;subplot(2,1,1);
plot(t(1:sub_t),sign_and_noise(1:sub_t),'b');
legend('原始','干扰后');
%原始信号的频率
N=2048;
SIG= abs(fft(signal,N));
SIG = fftshift(SIG);
F = [-N/2:N/2-1]/N;
figure;
subplot(3,1,1);
plot(F,SIG),title('原始信号的频率');
xlabel('频率');ylabel('振幅(dB)');
SIG_NOISE= abs(fft(sign_and_noise,N));
SIG_NOISE = fftshift(SIG_NOISE);
subplot(3,1,2);
plot(F,SIG_NOISE);title('被干扰信号的频率');
xlabel('频率');ylabel('振幅(dB)');
%创建一个理想的低通滤波器
f = [0:length(t)-1]/length(t);
low_pass = rectpuls(f, 0.15);
subplot(3,1,3);
plot(f, low_pass);title('低通滤波器');
xlabel('频率');ylabel('振幅(dB)');
%频率领域卷积
res_freq = fft(sign_and_noise) .* (low_pass);
res_time = real(ifft(res_freq));
figure(1);
subplot(2,1,2);
plot(t(1:sub_t), res_time(1:sub_t),'r'),title('重建的信号');xlabel('时间(s)');
subplot(2,1,2);
plot(t(1:sub_t), signal(1:sub_t),'b-.');
legend('复原后'); 展开
1个回答
展开全部
一步步运行+help+百度,就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询