Find energy for each second of audio file

조회 수: 22 (최근 30일)
Giggs B.
Giggs B. 2021년 7월 25일
댓글: Star Strider 2021년 7월 26일
Hi,
I have an audio signal which has 44.1 KHz sampling rate, which would be stored as an array. I am trying to find energy for each second using:
sum(x.^2);
Can someone help me how to do that? Thanks

채택된 답변

Star Strider
Star Strider 2021년 7월 25일
Use the buffer function:
Fs = 44.1E+3; % Sampling Frequency
s = randn(Fs*5.2,1); % Signal
seconds_sampled = 1; % Desired Smaple Length
sec1 = Fs*seconds_sampled; % Corresponding Samples
s_sections = buffer(s,sec1)
s_sections = 44100×6
1.5751 1.0628 0.3946 0.6711 -0.3298 -2.0274 1.5076 1.0714 0.6997 -1.6182 -0.7092 0.3166 -0.9737 0.2084 0.1273 -0.9344 0.6038 -0.0711 0.2128 0.7510 0.3992 -0.5763 -0.0085 -0.7977 -0.8026 1.5172 -0.1044 0.7109 0.4487 1.7293 0.1842 -0.8955 0.0778 -0.2759 -0.5885 1.3357 -0.7606 0.9031 -0.5579 -0.3093 -1.3640 0.1967 0.1805 1.6719 -0.8658 1.0763 0.9120 0.9080 0.0411 -0.1559 -0.9230 -1.8707 -0.3266 -1.5487 -1.1568 0.2762 0.5586 -0.8734 0.1023 1.6655
Check = size(s_sections)
Check = 1×2
44100 6
Energy = sum(s_sections.^2)
Energy = 1×6
1.0e+04 * 4.4284 4.3893 4.4579 4.4808 4.4129 0.9051
.
  댓글 수: 4
Giggs B.
Giggs B. 2021년 7월 26일
Got it, Thank you!
Star Strider
Star Strider 2021년 7월 26일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Signal Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by