Hello everyone. I am trying to make a for loop for my project. I am getting audiofiles named 1.wav to 50.wav . I am trying to calculate their energys. But i am changing audio names by my hand. Can I make a loop about it ? I tried that but not working :
for i=1:50
[data,fs]=audioread(['Sound(i).wav']);
end
energy(u)=0
a=length(data);
for l=1:a
energy(l)=(data(l)^2)+energy(l);
end

 採用された回答

KSSV
KSSV 2022 年 3 月 7 日
編集済み: KSSV 2022 年 3 月 7 日

0 投票

wavFiles = dir('*.wav') ;
N = length(wavFiles) ;
data = cell(N,1) ;
fs = cell(N,1) ;
for i=1:N
[data{i},fs{i}]=audioread(wavFiles(i).name);
end
You can access the data{1}, data{2}, ...data{N}

1 件のコメント

Mert Bilici
Mert Bilici 2022 年 3 月 7 日
Thanks a lot!!!

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

その他の回答 (1 件)

Jan
Jan 2022 年 3 月 7 日

0 投票

energy = zeros(1, 50);
for k = 1:50
[data, fs] = audioread(sprintf('Sound(%d).wav', k));
energy(k) = sum(data.^2); % ??? + energy(l);
end

1 件のコメント

Mert Bilici
Mert Bilici 2022 年 3 月 7 日
Thank you!!!

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

カテゴリ

ヘルプ センター および File ExchangeAudio Processing Algorithm Design についてさらに検索

製品

質問済み:

2022 年 3 月 7 日

コメント済み:

2022 年 3 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by