From: Peter Smith on 29 Jul 2010 13:09 Hi all I have around 310 .mat files all containing the same variables but for different days. For example one variable is spreadMat which contains spreads for various stocks for all minutes of the day. Ultimately i want to write a code which enables me to aggregate these minute by minute spreads into daily spreads. However first i need to load up all the spreadMat's from the different .mat files into matlab. Could someone suggest a clear solution to this problem. Many thanks
From: Andy on 29 Jul 2010 13:21 "Peter Smith" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i2scjg$30n$1(a)fred.mathworks.com>... > Hi all > I have around 310 .mat files all containing the same variables but for different days. > For example one variable is spreadMat which contains spreads for various stocks for all minutes of the day. > > Ultimately i want to write a code which enables me to aggregate these minute by minute spreads into daily spreads. However first i need to load up all the spreadMat's from the different .mat files into matlab. > > Could someone suggest a clear solution to this problem. > > Many thanks help dir Also, read the FAQ on processing files in batches.
From: us on 29 Jul 2010 13:27 "Peter Smith" <fe09ae(a)mail.wbs.ac.uk> wrote in message <i2scjg$30n$1(a)fred.mathworks.com>... > Hi all > I have around 310 .mat files all containing the same variables but for different days. > For example one variable is spreadMat which contains spreads for various stocks for all minutes of the day. > > Ultimately i want to write a code which enables me to aggregate these minute by minute spreads into daily spreads. However first i need to load up all the spreadMat's from the different .mat files into matlab. > > Could someone suggest a clear solution to this problem. > > Many thanks a hint: http://matlabwiki.mathworks.com/MATLAB_FAQ#How_can_I_process_a_sequence_of_files.3F us
From: ImageAnalyst on 29 Jul 2010 14:22 On Jul 29, 1:09 pm, "Peter Smith: After following the others advise, you could read them all into an array something like this: count = 0; myFolder = pwd; % Or whatever... % Get list of all mat files in this folder. matFiles = dir([myFolder '\*.mat']); % Loop through all the found files. for Index = 1:length(matFiles) % Get the full name of this particular mat file. baseFileName = matFiles(Index).name; fullFileName = fullfile(myFolder, baseFileName); % Read the variables of the mat file into a structure. storedStructure = load(fullFileName); % See if it has the field ("myVariableName") that we're looking for. hasField = isfield(storedStructure, 'myVariableName'); if hasField count = count + 1; % Save the value for this file to our array that % holds the values of all the files. arrayForAllFiles(count) = storedStructure.myVariableName; end end
|
Pages: 1 Prev: Best OS/platform for Matlab Next: reading scientific notation numbers from string |