Import txt. files from a folder for training data
2 views (last 30 days)
Show older comments
Mauritz Wilshusen
on 18 Mar 2022
Commented: Mauritz Wilshusen
on 21 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
0 Comments
Accepted Answer
Arif Hoq
on 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
More Answers (0)
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!