Import txt. files from a folder for training data

조회 수: 4 (최근 30일)
Mauritz Wilshusen
Mauritz Wilshusen 2022년 3월 18일
댓글: Mauritz Wilshusen 2022년 3월 21일
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