数字信号处理基础matlab

1.试实现编写一个被加性噪声污染的正弦信号产生的函数,该函数的输入参数为振幅 ,角频率 ,初始相位 ,信噪比SNR,长度为N。(matlab)

function  u = noise(A,w0, phi,SNR,N)
n=0:N-1;
x=w0*n+phi;
sine = A*sin(x);
sigma = A^2/(2*10^(SNR/10));
noise=sqrt(sigma)*randn(1,N);
u=sine+noise;
clc;
clear all;
close all;
A = 10;
w0 = 17*pi/9;
phi = pi/4;
[a,b] = numden(sym(2*pi/w0));
N = 100;

SNR = 10;
ud = noise(A,w0,phi,SNR,N);
n = 0:N-1;
subplot(2,1,1);
stem(n,ud);
xlabel('时间序号 n');
ylabel('振幅');
title('被加性噪声污染的正弦信号');

SNR = 50;
ud = noise(A,w0,phi,SNR,N);
n = 0:N-1;
subplot(2,1,2);
stem(n,ud);
xlabel('时间序号 n');
ylabel('振幅');
title('被加性噪声污染的正弦信号');

2.请使用randn产生在均值为mu, 方差为sigma的正态分布长度为N的随机信号。(matlab)

clc;  clear all;   close all;
N=100;
mu = 5;
sigma = 10;
ud = rand_fcn(mu, sigma, N)
n = 0:N-1;   % 定义序列的时间坐标
figure
stem(n, ud)
xlabel('时间序号 n');
ylabel('振幅');
title('正态分布随机信号');

猜你喜欢

转载自blog.csdn.net/weixin_46837674/article/details/109730206
今日推荐