Hi,
You can use fileDatastore for reading the text file and converting them into the required array for labels as it’s much easier and provide all the functionality required. You need to define a custom ReadFcn for reading the text files and formatting them carefully to create a vector out of each file. For reading text file you can use readmatrix if the file contains only vector with a specific delimiter otherwise textscan is suggested. I assume that since these are labels, they either be one-hot encoded or have a categorical number rather than a string for each class. If it’s a string class name then the textscan will provide cell array of string which can then be converted to specific class number to be useful for trainNetwork.
Hope it helps!
