I need to generate IPs for HDL implementation of an algorithm. I need to do fftshift in simulink but there is no fftshift block avaiable. Is there any way we can do fftshift of the output data from FFT block from DSP HDL toolbox? I am attaching FFT model for reference.

 채택된 답변

Walter Roberson
Walter Roberson 2025년 1월 23일

0 개 추천

Fork the fft output. Use https://www.mathworks.com/help/dsp/ref/variableselector.html variable selector block on each of the branches, with Fixed selector. In one of the branches select 1:floor(signal_length)/2 and in the other branch select floor(signal_length)/2+1:signal_length . Now concatenate those two together in reverse order.
This potentially requires hard-coding the signal length.

댓글 수: 3

This approach doesn't work for odd signal_length assuming the intent is floor(signal_length/2) (not floor(signal_length)/2)
x = 1:9;
signal_length = numel(x);
fftshift(x)
ans = 1×9
6 7 8 9 1 2 3 4 5
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[x(floor(signal_length/2)+1:signal_length), x(1:floor(signal_length/2))]
ans = 1×9
5 6 7 8 9 1 2 3 4
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
good point
x = 1:9;
signal_length = numel(x);
fftshift(x)
ans = 1×9
6 7 8 9 1 2 3 4 5
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
[x(ceil(signal_length/2)+1:signal_length), x(1:ceil(signal_length/2))]
ans = 1×9
6 7 8 9 1 2 3 4 5
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Paul
Paul 2025년 1월 24일
I just realized that this block requires the FFT length to be a power of 2, so the ceil() isn't necessary for this particular use case.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Paul
Paul 2025년 1월 23일
편집: Paul 2025년 1월 23일

0 개 추천

fftshift is extended to code generation. Assuming the data output from the FFT block is in linear order, you can call fftshift from inside a MatlabFunction block.

카테고리

제품

릴리스

R2023b

질문:

2025년 1월 23일

댓글:

2025년 1월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by