Import txt. files from a folder for training data

4 vues (au cours des 30 derniers jours)
Mauritz Wilshusen
Mauritz Wilshusen le 18 Mar 2022
How do Import *txt files from a folder into a cell array with nummeric array, or something else that is a suitable for training with a neural network.
I tried to import them via a FileDatastore:
x_train = fileDatastore("train\a_train\", "ReadFcn", @load);
y_train = fileDatastore("train\a_classification\", "ReadFcn", @load);
a = combine(x_train, y_train)
But this didn't seems to be the right format for training data. Sorry if this is a dump question, but its quite hard to figure out how to set up right training data.
The txt.files are all same as shown in this example. The Y_training data are just the same amount of txtfiles with just a 1,2 or 3 in it, for the 3 vowels I want to differentiate. Maybe there is also a smarter soultion for this.
It would be really helpfull, im a little bit lost so everything helps.
thx

Réponse acceptée

Arif Hoq
Arif Hoq le 18 Mar 2022
if you want to import all the text files,try this
textfiles = dir('*.txt');
numfiles = length(textfiles);
mydata = cell(1, numfiles);
for k = 1:numfiles
mydata{k} = load(textfiles(k).name);
% mydata{k} = open(textfiles(k).name);
end
this syntax, mydata{k} = open(textfiles(k).name) above will open all the text file in a matlab script.
Or, if you want to import a specific text file,then
A=readtable('a_fft - Kopie (1).txt','ReadVariableName',false); % if your text file contains numeric and string
A=readmatrix('a_fft - Kopie (1).txt'); % if your text file contains only numeric

Plus de réponses (0)

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by