how to load his code
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 7 Okt. 2018
Bearbeitet: Stephen23
am 7 Okt. 2018
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.
Antworten (1)
Stephen23
am 7 Okt. 2018
Bearbeitet: Stephen23
am 7 Okt. 2018
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:
0 Kommentare
Siehe auch
Kategorien
Mehr zu Characters and Strings 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!