Why am I getting NAN values for magnitudes when I use tfestimate?
7 次查看(过去 30 天)
显示 更早的评论
Hi all,
I am simulating a high frequency (6250 Hz) mass, spring and damper system's response to an impulse input.
My objective is to estimate how much noise can be on the measurement output to be able to determine the TF of the system with 1% accuracy in magnitude and 0.1% accuracy in frequency.
For this objective I am using the following system parameters:
% system parameters in the example
m = 9; %kg
d = 0.1; % damper value
res_freq = (6250)*2*pi; %6250 Hz I want to have a resonance peak.
k = m*(res_freq)^2; %stiffness value
s =tf('s');
G = 1/(m*s^2 + d*s +k);
Gd = c2d(G,5e-5);
opts = bodeoptions('cstprefs');
opts.PhaseVisible = 'off';
opts.FreqUnits = 'Hz';
figure;
bode(Gd,opts);
hold on
bode(G,opts);
grid on;
with the lines on plotting the bode of the continuous and discrete systems, I am able to confirm that the example is a valid one.
The system is simulated as follows:
Fs = 20000; %sampling rate is 20000 Hz
Ts = 1/Fs;
Ttot = [0: Ts: (2-Ts)]';
% create an impulse input for the length of 2 seconds.
L = length(Ttot);
dirac_input = 200 * ones(1,1); % dirac impulse with 200N force magnitude
input = [dirac_input; zeros(39999,1)];
x0 = [0 0];
oupt_NoNoise = lsim(Gd,input,Ttot,x0); %output from impulse without noise
%Adding noise to the simulation value: Tune this expression to understand noise sensitvity...
oupt_Noise = oupt_NoNoise+ (max(oupt_NoNoise)/100)*randn(length(oupt_NoNoise),1); % adding 1% noise.
With the output with and without noise simulated I performed the FFT of the two signals and I do notice the peak on the resonance frequency of the system as the most dominant freq. The signal with the noise had small amplitudes of other frequencies as well. So the output data is also as per my expectation.
Now, I am trying to see if I can recreate the system TF based on input and output data. So I do the following:
%% TF estimate with data that is noise free as well as data that is noisy.
nfft = 16384;
noverlap = nfft/2;
window = hann(nfft);
[txy,f] = tfestimate(input,oupt_NoNoise,window,noverlap,[],Fs); %getting tf estimate on data with no noise.
[txy_n,f_n] = tfestimate(input,oupt_Noise,window,noverlap,[],Fs); %getting tf estimate on data with noise.
figure;
plot(f, 20*log10(abs(txy)),'r');
hold on;
plot(f_n, 20*log10(abs(txy_n)),'b');
grid on;
and when I do this, I get that the values in variables txy and txy_n to be NAN. What is it that I am doing wrong in terms of using the tfestimate, can anybody please advice?
3 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Vibration Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!