Circular shift in MATLAB(with and without circshift)

preview_player
Показать описание
CODE:
Without built in function:

x_n=input('Enter the sequence:');
m=input('Enter required amount of shift:');
N=length(x_n);
X_K=fft(x_n,N);
K=0:N-1;
a=exp(-1i*((2*pi)/N).*K*m);
X2_K=X_K.*a;
x2_n=ifft(X2_K)

With built in function:

y_n=circshift(x_n,3)
Рекомендации по теме
Комментарии
Автор

At 7.25, there is one mistake. (.*) no need to give. Because K is array but ((2*pi)/N ) is not an array. So no need to give (.*) . You can give normal multiplication symbol.
So the code is:
x_n=input('Enter the sequence:');
m=input('Enter required amount of shift:');
N=length(x_n);
X_K=fft(x_n, N);
K=0:N-1;
a=exp(-1i*((2*pi)/N)*K*m);
X2_K=X_K.*a;
x2_n=ifft(X2_K)

KnowledgeAmplifier
join shbcf.ru