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