How to write several matlab variables into one struct array?

1 vue (au cours des 30 derniers jours)
Marc Hummel
Marc Hummel le 5 Avr 2016
Hey every one. Im new to matlab and have a little Problem. I want to read several files from different folders and save them all into wan struct list, to use the file names later. Everything is find until the point, where to 'for'-comand jumps from the 2nd to the 3rd folder. Then the code just writes the first file name into the new struct and leaves the rest. Can anyone please help me complete my code?
for k = 1 : numberOfFolders
% Get this folder and print it out.
thisFolder = listOfFolderNames{k};
fprintf('Processing folder %s\n', thisFolder);
filePattern = sprintf('%s/*.dat', thisFolder);
baseFileNames = dir([listOfFolderNames{k} '/*dat']); %filePattern);
numberOfFiles = length(baseFileNames);
if numberOfFiles >= 1
i = i+numberOfFiles;
baseFilename{i,1} =;
% Go through all those dat files.
for f = i : numberOfFiles
fullFileName {f,1} = fullfile(thisFolder, baseFileNames(f).name);
fprintf(' Processing dat file %s\n', fullFileName {f,1});

Réponses (1)

Walter Roberson
Walter Roberson le 5 Avr 2016
I suggest you use one of the recursive directory File Exchange contributions.


En savoir plus sur Structures dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by