Import txt. files from a folder for training data

2 次查看(过去 30 天)
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

采纳的回答

Arif Hoq
Arif Hoq 2022-3-18
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by