Dicrepancies in FFT values at lower frequencies
Show older comments
I have been trying to compare the time domain and frequency domain results from Matlab and ansys for a vibrating system. Although the values agree generally, at lower frequencies there appears to be a significant difference.Especially at 0, the amplitude varies significantly (in the time domain data,at time 0, both systems had the same amplitude). Why would that be? I have exported data from excel sheet for this analysis.
%Import time domain data from excel sheet
file = '....nt.xlsx';
sheet= '...';
data = xlsread(file,sheet);
time = data(:,1);
mat_amp = data(:,2);
ans_amp= data(:,3);
%% Frequency domain plot
L = length(time);
n=2^nextpow2(L);
Ts = time(2)-time(1);
Fs = 1/Ts;
f= Fs*(0:(n/2))/n;
ft_mat = fft(mat_amp,n);
M2 = abs(ft_mat/n);
M1 = M2(1:n/2+1);
M1(2:end-1)=2*M1(2:end-1);
ft_ans = fft(ans_amp,n);
A2 = abs(ft_ans/n);
A1 = A2(1:n/2+1);
A1(2:end-1)=2*A1(2:end-1);
figure(2)
plot(f,abs(M1),'-*',f,abs(A1)) ;
title("Frequency Response-Beam with Mass")
xlabel("f (Hz)")
ylabel("Amplitude")
grid on;
legend('Matlab', 'Ansys');
figure(3)
plot(f,20*log10(abs(M1)),'-*',f,20*log10(abs(A1)));
title("Frequency Response-Beam with Mass")
xlabel("f (Hz)")
ylabel("Amplitude in dB")
grid on;
legend('Matlab', 'Ansys');

10 Comments
Paul
on 22 Nov 2023
Assuming that we're looking at figure(3) as generated from the code in the question, it would seem that mat_amp and ans_amp are not the same data. Is that not the case?
Also, should ft_mat and ft_ans be divided by n or L?
Murali Krishnan
on 22 Nov 2023
Mathieu NOE
on 22 Nov 2023
hello
I don't know how the time domain data look like , but in general I compare systems based on transfer function estimates and no only on the response , which can sometimes led to inaccurate results like in your case
so can you perform the same comparison using tfestimate (with both input and output data) and not just the fft of the output ?
Murali Krishnan
on 22 Nov 2023
Paul
on 22 Nov 2023
As you showed below, you're taking the FFT of two different signals, so it's not a surprise that their FFT's are not the same. You're doing something different in Matlab and Ansys in how the time-domain data is generated from each tool.
The ampiitude of a signal at t = 0 is not directly related to the FFT amplitude at f = 0. The latter is proportional to the sum of all of the samples input to fft.
The issue with the division by L or n is only to get the correct amplitude at all frequencies, but won't change the fundamental nature of the frequency domain plot.
Murali Krishnan
on 22 Nov 2023
Mathieu NOE
on 22 Nov 2023
if your time data are impulse or step responses you can take advantage of knowing that info
I would recommend to use that data + info to identify a lightly damped two poles model , which should give you more accurate response plot vs simply doing the fft
and if you go that route , you can also use this code to find the natural frequency and damping of your 2 poles model
you can do this directly on your time data :
n = 1000;
Fs = 1e3; % sampling rate
dt = 1/Fs;
% dummy signal : exponential decaying sinus + constant
t = (0:n-1)*dt;
s = 5 + exp(-1.6*t).*sin(2*pi*3.3*t+1)+0.01*randn(size(t));
yu = max(s);
yl = min(s);
yr = (yu-yl); % Range of y
yz = s-yu+(yr/2);
zt = t(yz(:) .* circshift(yz(:),[1 0]) <= 0); % Find zero-crossings
per = 2*mean(diff(zt)); % Estimate period
ym = mean(s); % Estimate offset
fit = @(b,x) b(1) .* exp(b(2).*x) .* (sin(2*pi*x./b(3) + 2*pi/b(4))) + b(5); % Objective Function to fit
fcn = @(b) norm(fit(b,t) - s); % Least-Squares cost function
B = fminsearch(fcn, [yr; -1; per; -1; ym]) % Minimise Least-Squares
xp = linspace(min(t),max(t));
yp = fit(B,xp);
figure
plot(t, s, '-p',xp, yp, '-r')
Murali Krishnan
on 27 Nov 2023
Mathieu NOE
on 27 Nov 2023
my pleasure !
Answers (0)
Categories
Find more on Transforms 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!