What do these lines mean?

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 个)

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 个评论

@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);
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