フィルターのクリア

Saving extracted audio files in a For loop

4 ビュー (過去 30 日間)
whalelady
whalelady 2020 年 4 月 8 日
編集済み: Bhaskar R 2020 年 4 月 8 日
Hi, I am looking for some help.
I have a couple of audio files in a directory.
I extracted a portion of each audio file, and I want to save it into a new audio file.
How do I do it in a loop such that it is saved like in the following examples?
The below is my current code. Could someone vet for me especially the last two lines before end?
Thank you in advance!
Initial Files Extracted New Files
data_1.m4a extractedData_1.m4a
data_2.m4a extractedData_2.m4a
data_3.m4a extractedData_3.m4a
for p = 1:3
startSample = n;
endSample = length(data);
extractedData = data(startSample:endSample);
audiowrite(extractedData_,extractedData,fs);
filename = sprintf('%s%d.mat', extractedData_, p);
end

採用された回答

Bhaskar R
Bhaskar R 2020 年 4 月 8 日
編集済み: Bhaskar R 2020 年 4 月 8 日
wor_dir = 'your_directory_path'
for p = 1:3
startSample = n;
endSample = length(data);
extractedData = data(startSample:endSample);
file_ = sprintf('%s%d.m4a', 'extractedData_', p);
filename = fullfile(wor_dir, file_)
audiowrite(filename, extractedData,fs);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulation, Tuning, and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by