Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
54 views1 page

All All: %input ('Enter The Sequence') % ('Enter The Time Duration')

The document contains code to perform shifting and adding operations on input signals. It defines an input signal x, shifts it by 4 and -2 to create signals y1 and y2, adds them together with coefficients, and subtracts 2x to produce the output signal y. The shifts, additions, and output signal are plotted on subplots for visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views1 page

All All: %input ('Enter The Sequence') % ('Enter The Time Duration')

The document contains code to perform shifting and adding operations on input signals. It defines an input signal x, shifts it by 4 and -2 to create signals y1 and y2, adds them together with coefficients, and subtracts 2x to produce the output signal y. The shifts, additions, and output signal are plotted on subplots for visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Code

clc
clear all
close all

x = [1 -2 4 6 -5 8 10]; %input('enter the sequence')


n1 = -4:2; %('enter the time duration')

subplot(411);
stem(n1, x);
title('input signal');
xlabel('Index (n)');
ylabel('Amplitude');
[y1,n] = shifting(x,n1,4)
subplot(412);
stem(n, y1)
title('shifted by 4');
xlabel('Index (n)');
ylabel('Amplitude');
[y2,n2] = shifting(x,n1,-2)
subplot(413);
stem(n2, y2)
title('Shifted by -2');
xlabel('Index (n)');
ylabel('Amplitude');

% y = 3*y2+y1-2*x;

[sum1,n5] = signaladd(y1,n,3*y2,n2);
[y,n6] = signaladd(sum1,n5,-2*x,n1);
subplot(414);
stem(n6, y)
title('output signal');
xlabel('Index (n)');
ylabel('Amplitude');

Shifting
function [y,n] = shifting(x,n1,k)
n = n1+k;
y = x;
end

You might also like