📄 program_2_1.m
字号:
% Program 2_1 for example 2.1
% Generation of the ensemble average
%
N = 50; % The length of the signal
M = 20; % The times of measurement
n = 0:N-1; % The index of sinal
s = 2*n.*(0.9.^n); % Generate the uncorrupted signal
subplot(221);stem(n,s);xlabel('Time index n');ylabel('Amplitude'); title('Signal');
d = rand(N,1)-0.5; % Generate the random noise
x1 = s+d';
subplot(222);stem(n,d);xlabel('Time index n');ylabel('Amplitude'); title('Noise');
subplot(223);stem(n,x1);xlabel('Time index n');ylabel('Amplitude'); title('Noisy Signal');
for m = 1:M-1; % average
d = rand(N,1)-0.5;
x = s + d';
x1 = x1 + x;
end
x1 = x1/M;
subplot(224);h=stem(n,s);hold on;set(h,'MarkerFaceColor','red')
subplot(224);stem(n,x1);xlabel('Time index n');ylabel('Amplitude');
title('Comparison of original and averaged noisy signal');
legend('Original Signal','Averaged Noisy Signal',1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -