Azzera filtri
Azzera filtri

how to load his code

3 visualizzazioni (ultimi 30 giorni)
sam aldoss
sam aldoss il 7 Ott 2018
Commentato: sam aldoss il 13 Ott 2018
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 Commenti
Stephen23
Stephen23 il 7 Ott 2018
Modificato: Stephen23 il 7 Ott 2018
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 il 13 Ott 2018
size(current_folder) where I should post this am not an expert in matlab

Accedi per commentare.

Risposte (1)

Stephen23
Stephen23 il 7 Ott 2018
Modificato: Stephen23 il 7 Ott 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:

Categorie

Scopri di più su Characters and Strings in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by