Simulkink FFT Shift block
51 views (last 30 days)
Show older comments
Is there a simulink block that replicates the fftshift function. Bonus points if it is hdl
0 Comments
Answers (4)
Amish
on 6 Aug 2024 at 10:20
Hi Katherine,
The fftshift can be replicated in Simulink using a combination of "FFT Block" and "Premute" blocks.
The "FFT block" from the DSP HDL Toolbox provides architectures optimized for FPGA and ASIC application. You can configure the FFT block for your specific requirements and then use the "Permute" block to shift the FFT output to match the fftshift behavior.
Ensure that the "Output in bit-reversed order" option is unchecked, as we need a linear order for the fftshift.
The "FFT block" supports HDL Code Generation using the HDL Coder.
More information can be found in thew following documentation:
Hope this helps!
0 Comments
Sahas
on 6 Aug 2024 at 11:06
There is no exact block in Simulink that replicates the “fftshift” function of MATLAB. However, it is possible to create a Subsystem in Simulink that performs the same operations to achieve the same output as “fftshift” function for a 1-D vector by first splitting the vector into two halves, and then reordering the halves.
“Selector” and “Matrix Concatenate” blocks can be used for this purpose. Follow the steps given below to make the required Subsystem:
- Load the input vector in MATLAB base workspace.
- Define variables to determine the length of the vector and the middle index of the vector.
- Configure the Block Parameters of “Selector” block as given below.
- Arrange the required blocks in Simulink to get the desired output.
- This example is for a 1-D vector. Adjustments can be made based on specific requirements. After we get the desired output according to our specifications, we can convert it into a Subsystem.
- Remove all the “Display” blocks and select the “Selector” and the “Matrix Concatenate” blocks. Click on the “3 dots” in the corner and select “Create Subsystem”.
- Terminate the output from the Subsystem. This will create the required model.
To convert a custom-designed "fftshift" subsystem into HDL for hardware deployment purposes:
- Ctrl+E in Simulink to open the “Configurations Parameters” window and select the preferred language:
- Select the Subsystem and enter the following line in MATLAB Command Window:
>> makehdl(gcb)
3. This will convert the Simulink model in HDL. The required language file can be found by navigating to hdl_prj > hdlsrc > untitled > fft_shift_custom.v
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1747746/image.png)
For further information, refer to the MathWorks documentation links below:
- Basics of the “fftshift” function in MATLAB: https://www.mathworks.com/help/matlab/ref/fftshift.html
- Background of “Selector” block in Simulink: https://www.mathworks.com/help/simulink/slref/selector.html
- Background of “Concatenate” block in Simulink: https://www.mathworks.com/help/simulink/slref/vectorconcatenate.html
- Generate HDL Code of a Subsystem: https://www.mathworks.com/help/hdlcoder/ref/makehdl.html
0 Comments
Rahul
on 7 Aug 2024 at 6:58
I believe there is no direct block that you can use to achieve the functionality of 'fftshift' function.
As explained in this Answer: https://www.mathworks.com/matlabcentral/answers/95769-is-there-a-block-in-simulink-that-implements-the-fftshift-function-of-matlab
you can consider creating an Embedded MATLAB function block and using the 'fftshift' function inside it to achieve it's functionality in Simulink.
You can refer to the following documentation to know more about the 'fftshift' function: https://www.mathworks.com/help/releases/R2024a/matlab/ref/fftshift.html?searchHighlight=fftshift&s_tid=doc_srchtitle
Hope this helps! Thanks.
0 Comments
See Also
Categories
Find more on Transforms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!