Time Shifting in MATLAB (Code + Output)

You can do Time Shifting in Matlab with Discrete as well as Continuous signals. To time shift any discrete or continuous signal in Matlab, simply open and create a new Script (.m file) in Matlab.


Step 1:

Open MATLAB << Then on the top left corner click on the File option << Click New << Then click Script.



Step 2:

Now write the following Matlab code given below of Time Shifting into the new script (.m file) and save the file in the Matlab directory with any name you want.



TIME SHIFTING MATLAB CODE:

t = 1:1.5:20;

x = 2*sin(t);

subplot(3,1,1)

stem(t,x)

xlabel(‘Time Period’)

ylabel(‘Amplitude’)

title(‘Original Signal’)

subplot(3,1,2)

stem(t-5,x)

xlabel(‘Time Period’)

ylabel(‘Amplitude’)

title(‘Signal Shifted Left’)

subplot(3,1,3)

stem(t+5,x)

xlabel(‘Time Period’)

ylabel(‘Amplitude’)

title(‘Signal Shifted Right’)



 Step 3:

Now Run the code, after you have saved the file.


 

OUTPUT:

gHjRnmc90HT9gAAAABJRU5ErkJggg== - Time Shifting in MATLAB (Code + Output)

 

This is how you can Time Shift a signal 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!!