How to specify path name in sprintf?
42 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sangeet sagar
am 28 Jan. 2018
Kommentiert: Walter Roberson
am 28 Jan. 2018
I have a folder specified by the path D:\BTP\0 (1)\0 . This contains wave file ranging from 0 to 59 and I need to read each of them using the command
for m=0:59
filename = sprintf('%d.wav',m);
[s,fs] = audioread(filename);
end
I need to specify file name inside sprintf command. How do I do so?
0 Kommentare
Akzeptierte Antwort
Domanic
am 28 Jan. 2018
Bearbeitet: Domanic
am 28 Jan. 2018
You can do this through string concatenation:
mypath = 'D:\BTP\0 (1)\';
for m=0:59
filename = [mypath num2str(m) '.wav'];
[s,fs] = audioread(filename);
end
If it needs to be inside sprintf, you can use:
mypath = 'D:\\BTP\\0 (1)\\';
filename = sprintf([mypath '%d.wav'],m);
where the double slash, \\, generates the single \ in this context.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu SPICE files finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!