Use MATLAB to generate and plot a random sequence x[n], 0 lessthanorequalto n le
ID: 2082021 • Letter: U
Question
Use MATLAB to generate and plot a random sequence x[n], 0 lessthanorequalto n lessthanorequalto 50. Compute, plot and discuss the following operations: x_e[n] = x[n] + x[-n + 50]/2 and x_0[n] = x[n] - x[-n + 50]/2 for 0 lessthanorequalto n lessthanorequalto 50. Explain why these are called the even and odd components of the signal x[n]. x[2n] for 0 lessthanorequalto n lessthanorequalto 25. x[5n] for 0 lessthanorequalto n lessthanorequalto 10. 4 Sigma^4_m = 0^x[n - m] for 4 lessthanorequalto n lessthanorequalto 50. x[n]*x[n] = sigma^+infinty_m = -infinity x[m]x[m -n] for -50 lessthanorequalto n lessthanorequalto 50 where x[n] - 0 for n 50Explanation / Answer
clear all;
close all;
clc;
n = 50;% total number of randum numbers
x = rand(n,1)*10; % defining x(n)from n = 0 to n =50 total 51 randum numbers
% problem 1
for i=1:1:n
xe(i) = (x(i) + x(-n+51))/2; % the first element in matlab always starts at index 1.
xo(i) = (x(i) - x(-n+51))/2;
end
% problem 2
for i=1:1:n/2
x2n(i) = x(i*2); %time is multiplied in the brackets with a constant. this is called time scaling.
end
% problem 3
for i=1:1:n/5
x5n(i) = x(i*5); %time is multiplied in the brackets with a constant. this is called time scaling.
end
% problem 4
xnm=zeros(n,1);
for i=1:1:n-5
for j = 1:1:5 % m = 0 to 4 is same as j = 1 to 5
xnm(i) = xnm(i) + x(i-1+j); % this process accumulates the samples and adds them.
end
end
% code for generating various PLOTS is given below
% 1.
figure;
plot(x);grid; title('x(n)');
figure;
plot(xe);grid; title('xe(n)');
figure;
plot(xo);grid; title('xo(n)');
figure;
plot(xe+xo);grid; title('xe(n)+xo(n) this is equal to x the original signal');
% 2.
figure;
plot(x2n);grid; title('x2n(n)'); % this plot reduces the number of time samples by the constant term ie n/2
% 3.
figure;
plot(x5n);grid; title('x5n(n)'); % this plot reduces the number of time samples by the constant term ie n/5
% 4.
figure;
plot(xnm); grid;title(' sigma(0 to 4)x(n-m)');
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.