how to load his code

3 次查看(过去 30 天)
sam aldoss
sam aldoss 2018-10-7
评论: sam aldoss 2018-10-13
hello everyone, am working on some sound analysis on wav files which I have loaded into matlab and I run all other process but it show an under line where I have marked at the end and it show this massage can some one help please
%load audio file in to matlab
training_fds = fileDatastore(fullfile(pwd,'training'), 'ReadFcn', @importAudioFile, 'FileExtensions', '.wav', 'IncludeSubfolders', 1);
data_dir = fullfile(pwd, 'training');
folder_list = dir([data_dir filesep 'training*']);
for ifolder = 1:length(folder_list)
disp(['Processing files from folder: ' folder_list(ifolder).name])
current_folder = [data_dir filesep folder_list(ifolder).name];
reference_table = table();
% Import ground truth labels (1, -1) from reference. 1 = Normal, -1 = Abnormal
*_reference_table_* = [reference_table; importReferencefile([current_folder filesep 'REFERENCE.csv'])];
end
Consider preallocating a variable or array before entering the loop by using zeros, ones, cell, or a similar function. Preallocating avoids the need for MATLAB to copy the data from one array to another inside the loop. For examples of code that do and do not preallocate an array, see “Preallocating Arrays”.
  3 个评论
Stephen23
Stephen23 2018-10-7
编辑:Stephen23 2018-10-7
Why do you create a datastore object training_fds, but never use it?
Note that you call reference_table = table(); within the loop, so this will overwrite any existing reference_table from any previous loop iterations. Basically your loop does nothing as it discards all imported data, except for from the last iteration.
Tip: do not create filepaths using string concatenation. Use fullfile.
sam aldoss
sam aldoss 2018-10-13
size(current_folder) where I should post this am not an expert in matlab

请先登录,再进行评论。

回答(1 个)

Stephen23
Stephen23 2018-10-7
编辑:Stephen23 2018-10-7
Try something like this:
S = dir(fullfile('.','training*'));
N = {S([S.isdir]).name};
C = cell(1,numel(N));
for k = 1:numel(N)
F = fullfile('.',N{k},'REFERENCE.csv');
C{k} = importReferencefile(F);
end
All of the data will be in the cell array C. This is based on the examples in the MATLAB documentation:

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by