0% found this document useful (0 votes)
15 views2 pages

Circular Time Shift

The document describes a MATLAB script for performing circular time shifts and frequency shifts on a given sequence. It includes plotting the original and shifted sequences as well as their Discrete Fourier Transforms (DFTs). Additionally, it outlines a process for executing the Fast Fourier Transform (FFT) using a butterfly algorithm.

Uploaded by

roopa2875
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views2 pages

Circular Time Shift

The document describes a MATLAB script for performing circular time shifts and frequency shifts on a given sequence. It includes plotting the original and shifted sequences as well as their Discrete Fourier Transforms (DFTs). Additionally, it outlines a process for executing the Fast Fourier Transform (FFT) using a butterfly algorithm.

Uploaded by

roopa2875
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

% Circular Time Shift

x = input('Enter the sequence: '); % Input sequence

N = length(x); % Length of the sequence

l = input('Enter the shift amount: '); % Shift amount

x_shifted = circshift(x, [0, l]); % Circularly shifted sequence

% Plotting the original and shifted sequences

subplot(2,1,1);

stem(x);

title('Original Sequence');

subplot(2,1,2);

stem(x_shifted);

title('Circularly Shifted Sequence');

X = fft(x); % DFT of the original sequence

k = 0:N-1; % Frequency indices

f_shift = input('Enter the frequency shift amount: '); % Frequency shift amount

X_shifted = X .* exp(-1i * 2 * pi * f_shift * k / N); % Frequency shifted DFT

% Plotting the original and shifted DFTs

subplot(2,1,1);

stem(abs(X));

title('Original DFT Magnitude');

subplot(2,1,2);

stem(abs(X_shifted));

title('Frequency Shifted DFT Magnitude');

x = input("enter the sequence");

N = length(x); % Length of sequence


p=log2(N); % computing the number of conversion stages

Half=N/2; % half the length of the array

for stage=1:p % stages of transformation

for index=0:(N/(2^(stage-1))):(N-1) % series of "butterflies" for each stage

for n=0:(Half-1) % creating "butterfly" and saving the results

pos=n+index+1; % index of the data sample

pow=(2^(stage-1))*n; % part of power of the complex multiplier

w=exp((-1i)*(2*pi)*pow/N); % complex multiplier

a=x(pos)+x(pos+Half); % 1-st part of the "butterfly" creating operation

b=(x(pos)-x(pos+Half)).*w; % 2-nd part of the "butterfly" creating operation

x(pos)=a; % saving computation of the 1-st part

x(pos+Half)=b; % saving computation of the 2-nd part

end

end

Half=Half/2; % computing the next "Half" value

end

y=bitrevorder(x);

You might also like