return 0
return 0

Reputation: 4386

how to use save wav files to current subdirectory in matlab?

My current directory is under C, for example, "C:\xxx\"

Now, I want to export my processed wav files to a subfolder in my current directory, for example, "\wav_results\".

What I have done is declaring a filepath variable:

wav_dir = '\wav_results\';
wavwrite(...., [wav_dir wav_name]) %wav_name is the name of the wav file

The error says no such file or directory. I do not want to use the full directory path for wav_dir because I need to move this script from place to place. Anyone has good suggestion?

Thanks~

Upvotes: 1

Views: 1354

Answers (1)

Junuxx
Junuxx

Reputation: 14281

Use mkdir before you call wavwrite:

wav_dir = '\wav_results\'; %'
if not(exist('testresults','dir'))
    mkdir(wav_dir);
end
wavwrite(...., [wav_dir wav_name])

Upvotes: 1

Related Questions