Simulkink FFT Shift block
17 次查看(过去 30 天)
显示 更早的评论
Is there a simulink block that replicates the fftshift function. Bonus points if it is hdl
0 个评论
回答(4 个)
Amish
2024-8-6
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 个评论
Sahas
2024-8-6
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
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 个评论
Rahul
2024-8-7
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Transforms 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!