I'm trying to convert a .pkl 4D array into a datastore on MATLAB

3 次查看(过去 30 天)
I'm trying to convert a .pkl 4D array into a datastore on MATLAB, so that I can use the datastore to train a convolutional neural network. I have tried converting the .pkl file to a .mat, a .png and a .txt through python, but none have worked. When I try to convert the .mat file to the datastore using the code:
ds = datastore('folderpath', 'FileExtensions', '.mat', 'Type', 'tabularText')
I get the error "Cannot intepret data in the file 'filepath'. Found 3 variable names but 2 data columns. You may need to specifiy a different format, delimiter or number of lines.'

回答(1 个)

Ayush Modi
Ayush Modi 2024-5-23
Hi Hugh,
The tabularText type is intended for reading tabular data from text files, which doesn't match the structure of .mat files containing 4D arrays. For .mat files, you should consider using a fileDatastore. Here is an example to show how you can achieve this:
fds = fileDatastore('filename',"ReadFcn",@load,"FileExtensions",".mat");
data1 = read(fds);
For more information on fileDatastore function, refer to the following MathWorks documentation:

类别

Help CenterFile Exchange 中查找有关 Classification 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by