MATLAB - Specified all paths, but it's always

2019-08-18 22:46发布

sound_dirs={Ball, Daddy,Jeep, No, Tea_Pot};

The 5 variables in sound_dirs are path-char-vectors to 5 different sound folders.

  • data_structure is a cell of (length(num_sounds) row x 3 column cell
  • each row corresponds to a different sound
  • first column = directory name
  • second column = files struct for .wav files
  • third column = formant data

I want to be able to index into the files struct and do some processing on each .wav file of the same type, and then generate statistics on the group.

I use this method to get the '.wav' files

for i=1:num_sounds;
     i_num_wavs=length(data_structure{i,2});
     ith_file=data_structure{i,2};
     for j=1:i_num_wavs;
     [y Fs]= audioread(ith_file(j).name);
% end x 2 at the end of the processing

The problem:

The program I wrote always opens to the TeaPot Directory, which is the last directory. So when I call the ith term in the for loop, I somehow get TeaPot files and those don't match up.

I use this method to take off the last directory names to store in data_structure{i,1}

for i=1:num_sounds;
    path=sound_dirs{i};
[path, fname, ext] = fileparts(path); 
opendir = strcat(fname, ext);
words{i}=opendir;
end

Where is the logic wrong?

enter image description here

0条回答
登录 后发表回答