Digital signal processing basic matlab

1. Try to compile a function generated by a sinusoidal signal polluted by additive noise. The input parameters of this function are amplitude, angular frequency, initial phase, signal-to-noise ratio SNR, and length 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. Please use randn to generate a random signal with a normal distribution length of N with a mean value of mu and a variance of sigma. (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('正态分布随机信号');

Guess you like

Origin blog.csdn.net/weixin_46837674/article/details/109730206