mynoise

# mynoise - code works for a 10th order recursive moving...

This preview shows page 1. Sign up to view the full content.

% % % Matlab Project 2 continued % % Use and modify this this mfile to complete the assignment. % % % Change the order of the averaging filter from 2,5,10,100,1000 % % % For each order, describe in what you notice about the output signal y. % Why is the peak amplitude decreasing from 5 for higher orders? % What is happening at order = 1000? % Explain the quirks in this code to account for proper indexing. % for example, why must we use for i = 1:(nums(2)-order)? What is % nums(2)? % % This code computes the average nonrecursively. Can you rewrite this to solve recursively. % % To Turn in: % Plot of original input with noise (no averaging) % Plots of each output y after averaging % Type written descriptions and answers to questions. % Code for recursive computation of averaging and a plot showing that your
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: code works for a % 10th order, recursive, moving average filter. % % This file creates a siunusoid with added random noise k = -5:0.01:10; nums=size(k); % returns the dimension of k. .. 1 by 1501 u = 5*sin(k); % sinusoid with amplitude of 5 n = (rand(size(u))-0.5); % random sequence the same length noise with magnitude of unoisy = u + n; % adding the sinusoid and noise together order = 2; temp =0; for i = 1:(nums(2)-order); % We must index properly to only average elements in the array . .. 1 to (1501-"order") for j = 0:order-1 % Now we must add "order" consecutive elements temp=temp + unoisy(i+j); end y(i)=(1/order)*temp; % dividing finishes the averaging of "order" elements temp=0; end plot(y)...
View Full Document

Ask a homework question - tutors are online