Batch processing using loops
Show older comments
I'm trying to analyze multiple .mat files that only differ in the name of each file. I essentially want to run each file under the same code, but I don't want to laboriously change the name of the loaded file. Is there syntax that I could put in the front and end of my code so I can loop the script to run for all the files in a given directory. The .mat files only differ by a sequence of numbers within the name, so could I input some sort of string beforehand, so all matlab has to do is open files based on a prewritten string. I don't know if that made sense, I'm new to this program....Thanks for your patience.
This is an example of what I'm trying to do: The data vector are the numbers that vary from file to file. All I want to do is take these numbers, put them into a file name and load that file. Is this possible?
data = [110535, 112212, 113327, 114252, 115310, 120216, 121047, 121837, 123235, 124703, 125857, 131222,132322, 133328, 134052, 135138, 140132, 141120, 142016, 143316, 144304, 145623];
for k = data(1,i) kalmanized_data = sprintf('DATA20140218_%d.kalmanized.h5-short-only.mat', k); load (kalmanized_data); CODE end
Any help is appreciated!
Thank you!
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!