I have a spatial signal and need to do an fft over the frequency domain. I have seen a few different posts on the topic and there are varying approaches, none of which seem to work for me. The data comes from a simulation algorithm that is too long to post so I will just give the vector it outputs that I'm trying to transform (sorry in advance for the long vector)
if true EZ=[ 0 -0.1059 -0.1688 -0.1605 -0.0773 0.0592 0.2104 0.3347 0.4035 0.4113 0.3752 0.3226 0.2738 0.2291 0.1696 0.0728 -0.0670 -0.2277 -0.3688 -0.4530 -0.4640 -0.4103 -0.3115 -0.1835 -0.0338 0.1284 0.2829 0.3977 0.4416 0.3993 0.2840 0.1396 0.0311 0.0169 0.1100 0.2558 0.3543 0.3274 0.1851 0.0316 -0.0060 0.1193 0.3225 0.4348 0.3271 0.0154 -0.3404 -0.5530 -0.5485 -0.4102 -0.2888 -0.2661 -0.2952 -0.2663 -0.1289 0.0498 0.1454 0.0994 -0.0219 -0.0918 -0.0417 0.0876 0.2046 0.2612 0.2857 0.3301 0.3987 0.4360 0.3827 0.2421 0.0875 0.0010 0.0056 0.0611 0.1165 0.1520 0.1716 0.1716 0.1272 0.0141 -0.1530 -0.3088 -0.3773 -0.3324 -0.2213 -0.1282 -0.1068 -0.1418 -0.1707 -0.1338 -0.0035 0.2050 0.4153 0.5069 0.4096 0.1897 0.0057 -0.0342 0.0511 0.1656 0.2274 0.2095 0.1349 0.0544 0.0166 0.0374 0.0938 0.1464 0.1677 0.1521 0.1066 0.0376 -0.0539 -0.1603 -0.2536 -0.2912 -0.2428 -0.1167 0.0347 0.1367 0.1412 0.0790 0.0483 0.1145 0.2215 0.2358 0.0838 -0.1802 -0.4329 -0.5665 -0.5257 -0.3260 -0.0674 0.1062 0.1054 -0.0294 -0.1501 -0.1134 0.1025 0.3725 0.5206 0.4576 0.2468 0.0459 -0.0243 0.0284 0.0963 0.0916 0.0357 0.0288 0.1371 0.3108 0.4163 0.3500 0.1287 -0.1263 -0.2854 -0.2936 -0.1778 0];Lx = 0.08; %Total physical Length of cavity
n = length(EZ);N = Lx*linspace(0,1,n); %total space vector
dx = 5e-4; %spatial discretization
Fs = 1/dx; %spatial sampling frequency
k = 2*pi*N/(Lx); %wavenumber vector (?)
c = 1.4629e+008; %constant wave speed
f = 2*pi*c./k; %frequency vector
Y = abs(fft(EZ)/n);subplot(3,1,1)plot(N,EZ); xlabel('distance');subplot(3,1,2)plot(k,Y);xlabel('wave number');subplot(3,1,3)plot(f,Y);xlabel('frequency'); end
I don't use all the variables calculated in this version of the code. The fft results look wrong to me. My questions about the results are 1. Is the wave number vector correct? 2. Is the frequency vector correct? The frequency vector seems strange to me. A good thing is that Matlab seems to have plotted it backward for me (arrowing to the right with a data cursor makes it move left) so it appears in the right order. The theoretical values of the frequency fft should be somewhat larger but I don't know how to ensure I have made my axis vectors (k and f) correctly. Thanks in advance for any advice.
Best Answer