【问题标题】:Matlab finding natural frequency, interp1 function creates NaN valuesMatlab找到自然频率,interp1函数创建NaN值
【发布时间】:2016-07-17 16:44:30
【问题描述】:

我创建了以下代码,以查找通过使用冲击锤激发并连接有加速度计的测试样本的固有频率。但是,我被困在interp_accelerance_dB_first。这种插值创建了一组 NaN 值,我不知道为什么。我觉得这很奇怪,因为interp_accelerance 工作正常。我希望有人可以帮助我!

N = 125000;
fs = 1/(x(2)-x(1));
ts = 1/fs;
f = -fs/2:fs/(N-1):fs/2;

% Set x-axis of graph
x_max = (N-1)*ts;
x_axis=0:ts:x_max;

% find the first natural frequency between these boundaries 
First_lower_boundary = 15; 
First_upper_boundary = 30; 


Input = abs(fft(y)); %FFT input force
Output = abs(fft(o)); %FFT output acceleration

Accelerance = Output./Input;

bin_vals = [0 : N-1]; 
fax_Hz = bin_vals*fs/N; 
N_2 = ceil(N/2);

% Interpolate accelerance function in order to be able to average all accelerance functions 
Interp_accelerance = interp1(fax_Hz(1:N_2),Accelerance(1:N_2),x_axis); 


% --- Find damping ratio of first natural frequency 

% Determine the x-axis (from the boundries at the beginning of this script) 
x_axis_first_peak = First_lower_boundary:ts:First_upper_boundary;

% Accelerance function with a logarithmic scale [dB] 
Accelerance_dB_first =  20*log10(Accelerance(First_lower_boundary:First_upper_boundary));


% Interpolate the accelerance function [dB] 
Interp_accelerance_dB_first = interp1(fax_Hz(First_lower_boundary:First_upper_boundary),Accelerance_dB_first,x_axis_first_peak);

【问题讨论】:

  • xy的值是多少?

标签: matlab interpolation frequency nan frequency-analysis


【解决方案1】:

在不知道x,y,o 是什么的情况下很难确定,但通常interp1 在您尝试在数据x 轴边界之外进行插值时返回NaN。在代码末尾附加以下内容:

[min(fax_Hz(First_lower_boundary:First_upper_boundary)),max(fax_Hz(First_lower_boundary:First_upper_boundary))]
[min(x_axis_first_peak),max(x_axis_first_peak)]

如果第二个片段不在第一个片段之内,那么您就发现了问题。

顺便说一下,我认为interp_accelerance 可能会出现同样的错误,这又取决于输入参数的确切性质。

【讨论】:

  • 你是对的,第二个片段并没有落在第一个片段之内,interp_accelerance 也是如此。 x,y,o 参数直接从示波器中提取,具有 1x125000 双倍的性质。
  • 我对matlab知之甚少,我复制粘贴了代码并更改了一些东西,但不幸的是,效果不佳。你知道我能做些什么来解决这个问题吗?不管怎样,谢谢你的评论,这很有帮助!
  • 您在评论中添加的代码分别给出了min and max fax_Hz 0.7 和1.45 以及min and max x_axis_first_peak 15 和30。所以我猜是示波器产生的信号太弱了?
猜你喜欢
  • 1970-01-01
  • 2018-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-25
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多