What do these lines mean?

6 次查看(过去 30 天)
Mohamed Nedal
Mohamed Nedal 2015-8-25
Hi there, I want to know what do these two lines mean :
[q,v] = max(10*log10(p));
And
[s,f,t,p] = spectrogram(y,100,80,100,Fs);

回答(1 个)

Walter Roberson
Walter Roberson 2015-8-25
p is a vector or an array. log10(p) is logarithm base 10. Multiply that by 10. If the result is a vector, return the maximum value of the vector into q and return the location the maximum value was found at in v. If the result is an array, return the maximum value of each column into q and return the location of the maximum value in each column in v.
10*log10(x) is often used to calculate decibels.
Equivalent code would be
[maxp, v] = max(p);
q = 10*log10(maxp);
  2 个评论
Mohamed Nedal
Mohamed Nedal 2015-8-25
@Walter Robertson: Thank you very much for your answer. I have a couple of questions please :
1. You said that if the result is an array, return the maximum value of each column into q and return the location of the maximum value in each column in v. DO you mean return the location of the maximum value in each "row" in v or in each "colum" ?
2. What about the command line ?
[s,f,t,p] = spectrogram(y,100,80,100,Fs);
Walter Roberson
Walter Roberson 2015-8-25
编辑:Walter Roberson 2015-8-25
If you do not specify the dimension to work along and p is a 2D array, then [maxp, v] = max(p) would be equivalent to
for K = 1 : size(p,2)
[maxp(1,K), v(1,K)] = max(p(:,K));
end
That is, the maximum in each column.
I am not familiar with spectrogram() and I have to cut my lawn so I do not choose to study the topic at this time.

请先登录,再进行评论。

Community Treasure Hunt

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

Start Hunting!

Translated by