Out of memory while using FFT
10 次查看(过去 30 天)
显示 更早的评论
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 个评论
Matt J
2021-4-18
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.
回答(1 个)
Madhav Thakker
2021-5-18
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!