필터 지우기
필터 지우기

making loop mat lab

조회 수: 1 (최근 30일)
sam aldoss
sam aldoss 2018년 10월 8일
편집: Stephen23 2021년 4월 26일
hello
am working no signals using the code below I want to make this code to run for more then one folder can someone help please
clc,clear ,close all
% get a section of the sound file
[x, fs] = audioread('a14.wav'); % load an audio file
x = x(:, 1); % get the first channel
N = length(x); % signal length
t = (0:N-1)'/fs; % time vector
a14 = table(t, x);
writetable(a14, 'a14.csv', 'Delimiter',',')
  댓글 수: 1
sam aldoss
sam aldoss 2018년 10월 8일
no its not duplicate the code that I got it only load one file at time which good but think if you have more then 3000 file how you can run this code

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

채택된 답변

Stephen23
Stephen23 2018년 10월 8일
편집: Stephen23 2021년 4월 26일
"... but think if you have more then 3000 file how you can run this code"
Start by reading the MATLAB documentation:
This example is based on the one in the help:
P = 'directory where the files are saved';
S = dir(fullfile(P,'*.wav'));
S = natsortfiles(S); % optional, see below
for k = 1:numel(S)
[x,fs] = audioread(fullfile(P,S(k).name));
... your processing
S(k).data = any array that you want to store
end
All of the data will be in the data field of the structure S:
If you want the filenames to be read in alphanumeric order then you will need to sort them. An easy way to sort filenames into alphanumeric order is to download my FEX submission natsortfiles.
  댓글 수: 2
sam aldoss
sam aldoss 2018년 10월 8일
hello thanks a lot for you help its load some data which seem to be useful , but in this section its shows
Brace indexing is not supported for variables of this type.
Error in test1 (line 13) [x,fs] = audioread(fullfile(D,N{k}));
Stephen23
Stephen23 2018년 10월 8일
You need to have defined N as a cell array this:
N = {S.name};
or using natsortfiles, as I showed you. Cell arrays use brace indexing.

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

추가 답변 (1개)

Jayant
Jayant 2018년 10월 8일
you can try following
% get a section of the sound file
count=1;
for count=1:NumberOfFiles %% NumberOfFiles==> total number of your audio files
[x, fs] = audioread(['a' count '.wav']); % load an audio file like a1.wav, a2.wav, a3.wav...
x = x(:, 1); % get the first channel
N = length(x); % signal length
t = (0:N-1)'/fs; % time vector
a14 = table(t, x);
end
  댓글 수: 1
sam aldoss
sam aldoss 2018년 10월 8일
its saying Error using audioread (line 74) The filename specified was not found in the MATLAB path.

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

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by