Shifting a signal to the right or left
307 views (last 30 days)
Show older comments
How can I shift a signal to the left or right? Is there any inbuilt command for it?
Answers (6)
Jos (10584)
on 20 Sep 2019
x = 1:5
shift = 3
x = circshift(x,shift)
N = numel(x)
ix = (1:N) - shift
tf = ix < 1 | ix > N
x(tf) = 0
0 Comments
Manoj Kumar Koduru
on 23 Nov 2020
clc;
close all;
L=input ('Enter the no.: ');
n=-L:L;
y=[zeros(1,L),1,zeros(1,L)];
if n >0
y(L+1:end) = n(1:end-L);
elseif n <0
y(1:end+L) = n(-L+1:end);
end
y
plot(n,y);
Sk Group
on 8 Feb 2021
MATLAB CODE:
function [n1,x1] = sigshift(x,n,k)
n = 1:10;
k = 2;
x = exp(n);
if k>0
disp(‘Positive’);
n1 = n(1):n(end)+k;
x1 = [zeros(1,k) x];
else
disp(‘Negative’);
n1 = n(1)+k:n(end);
x1 = [x zeros(1,abs(k))]; % abs is for absolute value of (k) because quantity can never be (-ve) negative %
end
0 Comments
Sk Group
on 8 Feb 2021
MATLAB CODE:
function [n1,x1] = sigshift(x,n,k)
n = 1:10;
k = 2;
x = exp(n);
if k>0
disp(‘Positive’);
n1 = n(1):n(end)+k;
x1 = [zeros(1,k) x];
else
disp(‘Negative’);
n1 = n(1)+k:n(end);
x1 = [x zeros(1,abs(k))]; % abs is for absolute value of (k) because quantity can never be (-ve) negative %
end
MATLAB CODE:
function [y n1] = sigfold(x,n)
n1 = -fliplr(n)
y = fliplr(x)
end
0 Comments
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!