Approximate experimental data from multiple cells

Hello. I have several cell arrays with probe data from .mat-file.
I need to find resonance frequencies and q-factors for each of the 1000 inputs, and then estimate (approximate) them. However, the code below provides only 1 value of fres instead of 1000, and no plot for (i, fres) is shown. (I attached a frequency-amplitude plot)
  • FStart - cell array (1000*1)
  • FEnd - cell array (1000*1)
  • Amp - multiarray (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*AmpA2(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
NB: the last FStart value is less than the first FreqEnd value
Futhermore, I try to esteem the Q factor as: Max(frequency on level = 1/2*MaxAmplitude)-Min(frequency on level = 1/2*MaxAmplitude)
fmin = min(f1(Q_Index))
fmax = max(f1(Q_Index))
But it shows fmin = fmax
Could you please tell, what's the problem here?

3 件のコメント

KSSV
KSSV 2017 年 7 月 12 日
YOu have not shown what is f2 ? And the question is based on f2.
Elaine Carroll
Elaine Carroll 2017 年 7 月 12 日
Excuse me, that's f1, too, I'll edit it.
Guillaume
Guillaume 2017 年 7 月 12 日
You say that FStart and Fend are cell arrays, yet your code has
f1 = FStart(i):10:FEnd(i);
which would cause an error if they were indeed cell arrays. Are they actually just plain matrices (in this case vectors)?

サインインしてコメントする。

回答 (1 件)

Guillaume
Guillaume 2017 年 7 月 12 日
編集済み: Guillaume 2017 年 7 月 12 日

0 投票

But it shows fmin = fmax Well, of course. I don't understand what you're trying to do but you have:
[Q_Value, Q_Index] = max(0.5*AmpA2(i,:))
fmin = min(f1(Q_Index))
fmax = max(f1(Q_Index))
so AmpA2(i, :) is a column vector from which you're taking the maximum and its location Q_index. There is only ever one Q_Index value returned by max. Therefore f1(Q_Index) is a scalar value. The minimum and maximum of a single value is the same: that single value.
Also: see comment to the question, above, about the cell arrays.

1 件のコメント

Elaine Carroll
Elaine Carroll 2017 年 7 月 12 日
編集済み: Elaine Carroll 2017 年 7 月 12 日
Thank you for the answer. I understand that there was 1 value, I pointed that out. fres(i) instead of fres solved my problem. I was trying to get an array for fres.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2017 年 7 月 11 日

編集済み:

2017 年 7 月 12 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by