Shifting a signal to the right or left
Mostra commenti meno recenti
How can I shift a signal to the left or right? Is there any inbuilt command for it?
6 Commenti
SSG_newbiecoder
il 1 Feb 2018
Modificato: SSG_newbiecoder
il 6 Feb 2018
Jos (10584)
il 6 Feb 2018
maybe you should give an example of the input and expected output?
SSG_newbiecoder
il 6 Feb 2018
Modificato: SSG_newbiecoder
il 6 Feb 2018
mathematics
il 15 Set 2019
Sk Group
il 24 Gen 2021
https://www.swebllc.com/signal-shift-function-in-matlab/
Risposte (6)
Jos (10584)
il 20 Set 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
SSG_newbiecoder
il 20 Set 2019
2 voti
Jos (10584)
il 1 Feb 2018
x = 1:10
k = 3
xs = circshift(x,k)
Manoj Kumar Koduru
il 23 Nov 2020
0 voti
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);
1 Commento
Shukumar Pattnaik
il 10 Feb 2021
sir what is the use of line 5 ??
Sk Group
il 8 Feb 2021
0 voti
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
Sk Group
il 8 Feb 2021
0 voti
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
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!