Matlab The following MATLAB commands creates a sine-shaped signal y(t) that cont
ID: 3808885 • Letter: M
Question
Matlab The following MATLAB commands creates a sine-shaped signal y(t) that contains random noise: t = 0:.05:10; y = sin(t) -0.1 + 0.2 * rand(1, length(t)); Write a MATLAB program that use these commands to creates a noisy sine-shaped signal. Then the program smooths the signal by using the threepoints moving average method. In this method the value of every point i, except the first and last, is replaced by the average of the value of three adjacent points (i-1, i, and i + 1). Make a plot that display the noisy and smoothed signals.Explanation / Answer
Matlab code:
clc; clear all;close all;
t = 0:0.05:10;
y = sin(t) - 0.1 + 0.2*(rand(1,length(t)));
plot(t,y,'b');
hold on;
z = y;
for i = 2:(size(t,2) - 1)
z(i) = ( y(i-1) + y(i) + y(i+1) )/3;
end
plot(t,z,'r');
xlabel('x');
ylabel('y');
legend('Original signal', 'Signal with AGWN')