I checked your request and problem, lets begin with an example from the call of the data.
location = 'Data/Train';
imds = imageDatastore(location, 'FileExtensions', '.mat', 'IncludeSubfolders',1, ...
In the folder "Train" i have the 4 subfolders of each category, and in each subfolder, there are 100 .mat file with the data.
Then, parametrize the store variable:
trainingDS = imds;
trainingDS.Labels = categorical(trainingDS.Labels);
trainingDS.ReadFcn = @readFcn1;
About the readFcn1, you only have to copy this in your read function:
function I = readFcn1(filename)
I = load(filename);
I = I.signaldata;
However, there is an important annotation that need to take into account, If you can see, I save the data in a variable called "I", and then, rewrite the variable with a "I.signaldata". The parameter signaldata is THE NAME OF YOUR VARIABLE IN THE .mat file, so you had to save all data with the same name in the work space, so when you load the mat file, it will have the same name for matlab, for example: I saved my ".mat" files with the name (signal1, signal2, signal3.mat... and so) but the variable in it is called "signaldata", so, all .mat have the same variable name but with different data inside.
If you dont call your variable iside the mat file with the same name, it make complicated to read the data.
you asked for the "filename" variable... no, it keep that name, because is called directly from the function.
Also, i highly recommend you to save the data inside of your variable as an "double array", because the CNN cant read "cell, struct", and so as input data. An also, the CNN only work with 1 or 3 channels, not with 2 or +4. so you would need to reorganize your data in 1 or 3 channels.
Hope it helps