フィルターのクリア

Custom DFT function for even and odd samples

5 ビュー (過去 30 日間)
WarriorPlatypus
WarriorPlatypus 2021 年 4 月 20 日
回答済み: Nadia Shaik 2022 年 2 月 3 日
I'm trying to create a custom DFT function using circshift for even and odd samples but the odd part is not working. I appreciate if someone can help.
function X_k = my_DFT(x,N)
L = length(x);
if N < L
error(' N < L')
elseif N > L
xn = zeros(1,N); %zero padding
xn(1:L) = x;
else % N == L
xn = x;
end
if rem(N, 2) == 0
n = 0 : N-1;
k = 0 : N-1;
CoefMatrix = exp(1i * (2*pi/N) * k' * n);
X_k = CoefMatrix * xn';
X_k = circshift(X_k',N/2);
else
n = 0 : N-1;
k = 0 : N-1;
CoefMatrix = exp(1i * (2*pi/N) * k' * n);
X_k = CoefMatrix * xn';
X_k = circshift(X_k',N/2 + 1); %?
end
end
  2 件のコメント
Mohammed Samir
Mohammed Samir 2021 年 4 月 20 日
l=length(x);
if(l<N)
x=[x zeros(1,(N-1))];
else if(l>=N)
x=[x(1:N)];
end
WarriorPlatypus
WarriorPlatypus 2021 年 4 月 20 日
Excuse me I dont think this would work...

サインインしてコメントする。

回答 (1 件)

Nadia Shaik
Nadia Shaik 2022 年 2 月 3 日
Hello,
It is my understanding that you are trying to create a custom DFT function for even and odd samples of the input using circshift function.
You may refer to the below mentioned code example:
function X_k = my_DFT(x,N)
L = length(x);
if N < L
error(' N < L')
elseif N > L
xn = zeros(1,N); %zero padding
xn(1:L) = x;
else % N == L
xn = x;
end
if rem(L, 2) == 0
n = 0 : N-1;
k = 0 : N-1;
CoefMatrix = exp(1i * (2*pi/N) * k' * n);
X_k = CoefMatrix * xn';
X_k = [X_k(1) circshift(X_k(2:end)',N-1)];
else
n = 0 : N-1;
k = 0 : N-1;
CoefMatrix = exp(1i * (2*pi/N) * k' * n);
X_k = CoefMatrix * xn';
X_k = circshift(X_k',N); %?
end
end
I hope it helps you.

カテゴリ

Help Center および File ExchangeMatched Filter and Ambiguity Function についてさらに検索

製品


リリース

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by