08-26-2020 07:28 AM
Hi
I would like to perform the following matlab operation in labview for a 3D array:
r =fftshift(fftn((p));
where p is a 3D array.
I found the following code that allows me to perform a 3D fft:
so i can perform : r =fftn(p); successfully in labview for a 3D array
but i am not sure how to modify the code to implement the 3D fftshift. I tried changing the code by enabling the fft shift in the initial 2D FFT and the column 1D FFT as shown in the attached photo but it did not work...
09-22-2020 06:24 PM
Here's one implementation of LabVIEW code that imitates MATLAB's fftshift() function:
No guarantee it's efficient (in fact, I suspect that for very large data sets, it will be quite inefficient). But it works.
(I'm curious what some of the more expert LabVIEW forum members could do with this code...)
You can compare it to the output in this MATLAB code:
% Creating the matrix that's default in the LabVIEW code
m = 4; % Number of Pages
n = 5; % Number of Rows
o = 6; % Number of Columns
for k = 1:m
for j = 1:n
for i = 1:o
x(j,i,k) = i + (j-1)*o + (k-1)*n*o;
end
end
end
% Performing the fftshift()
fftshift(x)
In case you're interested, MATLAB just performs this by rotating the matrix about half-way in each dimension. LabVIEW has a "Rotate 1D Array" function that would more closely imitate the MATLAB code, but I struggled grabbing the correct 1D arrays to rotate in the page-direction. What I did here is functionally equivalent.
Hope this helps!
-joeorbob