Signal Shift function in MATLAB

You can make a signal shift function in Matlab and can use it as a calling function in any operations, codes and files in Matlab. To do this simply open and create a new Script (.m file) in Matlab.

  1. Open MATLAB << Then on the top left corner click on the File option << Click New << Then click Script.
  2. Now write the following Matlab code given below of signal shift function into the new script (.m file) and save the file in the Matlab directory with any name you want.


function [n1,x1] = sigshift(x,n,k)

n = 1:10;

k = 2;

x = exp(n);

if k>0


    n1 = n(1):n(end)+k;

    x1 = [zeros(1,k) x];



    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 %


Now, here I’m gonna give you an example of how we can use our sigshift function which we created in any operations or files in Matlab. For this create a new file and write the following input code given below and run.


n = 1:10;

k = 2;

x = exp(n);

[n1,x1] = sigshift(x,n,k) % here we used our sigshift function %



title(‘Original Signal’)



title(‘Shifted Signal’)


image edited - Signal Shift function in MATLAB

image 1 1024x576 - Signal Shift function in MATLAB

This is how you can make a Signal Shift function in MATLAB. Hope you like this article. If you want to learn more about MATLAB you can read and view all the blog posts related to MALTAB here. MATLAB Learning 

If you need any help and assistance, please comment down below so that we can help you. Good Luck!!