MATLAB - Specified all paths, but it's always opening to the last path?

谁都会走 提交于 2019-12-25 04:18:24

问题


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?

来源:https://stackoverflow.com/questions/55678142/matlab-specified-all-paths-but-its-always-opening-to-the-last-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!