Question
What’s the answer for (a) and (b) using Matlab?
Problem 1: Consider the following sequences x(n) = {-4, 5, 1,-2,-3, 0, 2, 45),-35ns4 y(n) = {6,-3,-1, 0, 8, 7,-2).-Isn 5 n(n) = {3, 2, 2,-1, 0,-2,5), 2sns8 The sample values of each of the above sequences outside the ranges specified are all zeros. Generate and plot the following sequences using MATLAB functions (c.g SIGSHIFT, SIGADD, fold, shift, etc.): (a) u(n) = x(n) + y(n-2) (b) s(n) =-y(n) + w(n + 4) 110 points 110 points
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

The SIGSHIFT and SIGADD are the minor programs which can be downloaded from the web easily.

Following is the program that evaluates the (a) and (b) part:

clc; clear variables;
% Given Data
n1 = -3:4; % Domain for Seq_1
n2 = -1:5; % Domain for Seq_2
n3 = 2:8; % Domain for Seq_3
x = [-4 5 1 -2 -3 0 2 4.5];
y = [6 -3 -1 0 8 7 -2];
w = [3 2 2 -1 0 -2 5];
%% Solution
% 1) To find u(n) = x(n) + y(n-2)
% First we will shift y by 2 and then add x
[Y_new , n2_new] = sigshift(y,n2,2);
[u , n_u] = sigadd(x,n1,Y_new,n2_new);
figure(1)
plot(n_u,u)
grid on
xlabel('n');
ylabel('u')
% 2) To find s(n) = -y(n) + w(n+4)
Y_negative = -y;
[W_new , n3_new] = sigshift(w,n3,-4);
[s , n_s] = sigadd(Y_negative,n2,W_new,n3_new);
figure(2)
plot(n_s,s)
grid on
xlabel('n');
ylabel('s')

The above program uses SIGSHIFT and SIGADD which are as follows:

SIGSHIFT

function [y,n] = sigshift(x,m,n0)

% implements y(n) = x(n-n0)

% -------------------------

% [y,n] = sigshift(x,m,n0)

%

n = m+n0; y = x;

SIGADD

function [y,n] = sigadd(x1,n1,x2,n2)

% implements y(n) = x1(n)+x2(n)

% -----------------------------

% [y,n] = sigadd(x1,n1,x2,n2)

% y = sum sequence over n, which includes n1 and n2

% x1 = first sequence over n1

% x2 = second sequence over n2 (n2 can be different from n1)

%

n = min(min(n1),min(n2)):max(max(n1),max(n2)); % duration of y(n)

y1 = zeros(1,length(n)); y2 = y1; % initialization

y1(find((n>=min(n1))&(n<=max(n1))==1))=x1; % x1 with duration of y

y2(find((n>=min(n2))&(n<=max(n2))==1))=x2; % x2 with duration of y

y = y1+y2; % sequence addition

Following are the plots obtained :

a) 8 6 2 0 2 -3 2 1 012 3 4567

b)

Add a comment
Know the answer?
Add Answer to:
What’s the answer for (a) and (b) using Matlab? Problem 1: Consider the following sequences x(n)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT