- Replicate your 2D matrix along the third dimension to simulate a 3D dataset.
- Apply the fftn function to perform the 3D Fourier transform.
FFTN on 2D distribution
15 views (last 30 days)
Show older comments
I got a known 2D distrubution of a magnetic field and and the following equations to expand my field with 3D Fourier Series:
and are the amplitudes of the harmonics, and are the phase angles. After some research I found matlab's fftn command. But I dont quite understand how I need to prepare my data and so I can feed it properly to the algorithm and get results for and .
Let's assume I got a 2D-matrix with amplitudes of my magnetic field strength ( and ):
S = rand(10,10)
Since The output Y is the same size as X according to the description, I need to modifiy the matrix first. Is this done via a meshgrid or do I understand something wrong?
0 Comments
Answers (1)
Shubham
on 8 Nov 2024 at 8:39
It seems you are trying to perform a 3D Fourier transform on a 2D data matrix using MATLAB's fftn function. Since the original data is 2D, you will need to extend it into a 3D matrix. Here's a how you can achieve this:
Here's an example in MATLAB:
% Assuming S is your 2D matrix
S = rand(10, 10);
% Extend S to a 3D matrix by replicating it along the third dimension
S3D = repmat(S, [1, 1, 10]); % Creates a 10x10x10 matrix
% Perform 3D FFT
Y = fftn(S3D);
% Y will be a 3D matrix of the same size as S3D
The output Y will be a 3D matrix containing complex numbers that represent the amplitudes and frequency components of your data. While meshgrid is helpful for creating coordinate grids for plotting, it is not required for using fftn.
For more information on fftn, refer to the following documentation link:
Hope this helps.
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering 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!