我有几个单元格数组,其中包含来自 .mat-file 的探针数据。
我需要找到 1000 个输入中每个输入的共振频率和 q 因子,然后估计(近似(它们。但是,下面的代码仅提供 1 个 fres 值而不是 1000,并且没有显示 (i, fres( 的绘图。
- FStart - 电池阵列 (1000*1(
- FEnd - 电池阵列 (1000*1(
-
放大器 - 多阵列 (1000*100(
for i = 1:1:1000 f1 = FStart(i):10:FEnd(i); grid on y1 = plot(f1,Amp(i,:)); [maxValue, maxIndex] = max(Amp(i,:)); %find maximum value of amplitude for each i [Q_Value, Q_Index] = max(0.5*Amp(i,:)); %also tried 0.5*max() and /2 fres = f1(maxIndex); %by index of max amplitude value find resonance frequency plot(i,fres) %plot resonance frequency for each i hold on end
注意:最后一个 FStart 值小于第一个 FreqEnd 值
此外,我尝试将Q因子视为:最大(电平频率= 1/2*最大振幅(-最小(电平频率= 1/2*最大振幅(
fmin = min(f2(Q_Index))
fmax = max(f2(Q_Index))
但它显示 fmin = fmax
你能说说,这里有什么问题吗?
除了对答案的注释清楚地表明问题所在之外,您还可以通过将fres
存储为向量来从脚本中删除plot
:
for i = 1:1000
f1 = FStart(i):10:FEnd(i);
grid on
y1 = plot(f1,Amp(i,:));
[maxValue, maxIndex] = max(Amp(i,:)); %find maximum value of amplitude for each i
[Q_Value, Q_Index] = max(0.5*Amp(i,:)); %also tried 0.5*max() and /2
fres(i) = f1(maxIndex); %by index of max amplitude value find resonance frequency
end
plot(1:1000,fres,'ko-','LineWidth',2)