Out of memory while using FFT
8 views (last 30 days)
Show older comments
I'm trying to plot the field for a FDTD simulation in frequncy domain but I keep running into memory error. I've attached my code below.
Nfft = nt *8;
df = 1/(Nfft*dt);
ftEZ = abs(fft(Ez_out,Nfft));
fmax = 600e6;
numfSamps = floor(fmax/df);
fr = df*(0:numfSamps-1);
figure;
plot(fr,ftEz(1:numfSamps));
ylabel('Amplitude (V/m)');
xlabel('Frequency (Hz)');
set(gca,'FontSize',16);
hold on;
p = ftEz(1:numfSamps);
[peaks,locs] = findpeaks(p,'MinPeakDistance',width, 'MinPeakHeight',height);
f110 = 2.998e8/2/pi*sqrt(2*pi^2);
f210 = 2.998e8/2/pi*sqrt((2*pi^2)+pi^2);
nf110 = floor(f110/df);
nf210 = floor(f210/df);
fex = [f110,f210];
aex = [ftEz(nf110), ftEz(nf210)];
plot(fex,aex,'ro');
legend('FDTD sim','Exact','location','northwest');
%%%%%Error Message%%%%%
Error using fft
Requested array exceeds the maximum possible variable size.
Error in Trail_code (line 179)
ftEZ = abs(fft(Ez_out,Nfft));
More information
2 Comments
Matt J
on 18 Apr 2021
We don't know what the value of nt is, but isn't the cause of the problem obvious from the erorr message? Your Nfft must be absurdly big.
Answers (1)
Madhav Thakker
on 18 May 2021
Hi Sreenidhi,
The variable nt has value 3.5886e+13 which is due to which the resulting Fourier transform array exceeds the maxiumum variable size.
Hope this helps.
0 Comments
See Also
Categories
Find more on Mathematics and Optimization 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!