필터 지우기
필터 지우기

I have lots of wave file. How do I read each one of them using sprintf command?

조회 수: 1 (최근 30일)
The wave file are like.The first digit- speaker id, second digit-utterence id
  • 00
  • 01
  • 02
  • 03
  • 04
  • .
  • .
  • .
  • 59
I tried using
for m=0:5
for y=0:9
file=sprintf('%s%d%d','E:\0 (1)\0\',m,y);
[s,fs]=wavread(file);
end
end
But this gives error. Alternatively I tried
mypath = 'E:\\0 (1)\\0\\';
filename = sprintf([mypath '%s%d.wav'],m,y);
[s,fs] = audioread(filename);
But it gave error as : Function is not defined for sparse inputs.
Please help me.

채택된 답변

Walter Roberson
Walter Roberson 2018년 1월 28일
mypath = fullfile('E:', '0 (1)', '0');
for m = 0 : 5
for y = 0 : 9
filename = fullfile(mypath, sprintf('%d%d.wav', m, y));
[s, fs] = audioread(filename);
...
end
end
Or in your situation you could use a single loop:
mypath = fullfile('E:', '0 (1)', '0');
for idx = 0 : 59
filename = fullfile(mypath, sprintf('%02d.wav', idx));
[s, fs] = audioread(filename);
...
end
  댓글 수: 4
Image Analyst
Image Analyst 2018년 1월 28일
Your first code:
for m=0:5
for y=0:9
file=sprintf('%s%d%d','E:\0 (1)\0\',m,y);
[s,fs]=wavread(file);
end
end
gets the file (perhaps) but doesn't do anything with the s and fs it retrieved.
There are ways you could make your code more robust, for example by checking in advance if the file exists before calling wavread(), and by updating to the new function audioread(), etc.
See the FAQ.
Walter Roberson
Walter Roberson 2018년 1월 28일
Which function does it say is not defined for sparse input?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by