0% found this document useful (0 votes)
27 views2 pages

Shifted and Flipped Signal of Mid I

The document provides code to define a signal g(n) and plot it. It then uses sigfold and sigshift functions to take the signal g(n) and produce g(2-n), plotting the result. The sigfold function flips the x and y values to reverse the signal. The sigshift function shifts the n values by the input amount (no) to produce the shifted signal g(2-n).

Uploaded by

Fakhar Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Shifted and Flipped Signal of Mid I

The document provides code to define a signal g(n) and plot it. It then uses sigfold and sigshift functions to take the signal g(n) and produce g(2-n), plotting the result. The sigfold function flips the x and y values to reverse the signal. The sigshift function shifts the n values by the input amount (no) to produce the shifted signal g(2-n).

Uploaded by

Fakhar Abbas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Following is the required signal of g(2-n)

Code is as Follows:

clc;clear all;close all


n=-8:8;
g_n=[6:-2:-4 -2 0 2*ones(1,4) -2*ones(1,4) 2]; %
Defines g(n)
figure(1)
stem(n,g_n,'filled')
set(gca,'XTick',-8:8);% gca stands get handle to
current axis. it shows all values
% from -8 to 8
set(gca,'YTick',-6:6);
xlabel('n')
title('g(n)')
grid
[x21,n21]=sigfold(g_n,n);
[g2_n,m]=sigshift(x21,n21,2)
figure(2)
stem(m,g2_n,'filled')
set(gca,'XTick',-8:10);% gca stands get handle to
current axis. it shows all values
% from -8 to 8
set(gca,'YTick',-6:6);
xlabel('n')
title('g(2- n)')
grid

Where functions are as follows

function [y,n]=sigfold(x,n)
n=-fliplr(n);
y=fliplr(x);
end

function [y,n]=sigshift(x,n,no)
n=n+no;
y=x;
end

You might also like