How to loop through a folder of ifiles in Matlab
5 views (last 30 days)
Show older comments
Hello all,
I have a lack of efficiency of my script that it could be sort out whether I were able to loop through a folder where I have all my files.
The script is working fine the only thing is that I have to go file by file loading them. I have searched for information of how to do it and most of it explain how to get txt. .cvs. jpg and so on. However, I have a bunch of Ifiles coming from AVL combustion system, which I am not sure how to load them one by one in a loop.
The idea it would to run a loop where you can load each ifile in a function to extract all the variables only selecting the folder. I have managed to have everything working but I am stack in that step. In this way, I could leave the script overnight working rather than the need to go one by one.
Any help it would be more than welcome.
Thank you very much.
Cruz
Accepted Answer
TADA
on 19 Dec 2018
Edited: TADA
on 19 Dec 2018
I Have No Idea What Is This ifile format. But This File Exchange Seems Exactly Like What You're Looking For:
3 Comments
TADA
on 19 Dec 2018
Ok, so you only need to iterate through your files?
I think this should do the it:
path = pwd; % set your folder path here
filePattern = '*.ifile'; % or whatever file extension these files are saved as
files = dir([path '\' filePattern]);
fileNames = strcat({files.folder}, '\', {files.name});
% I think that load_ifile returns a struct?
% If you know in advance what fields it has, and all structs have the same
% fields, you can use a struct array instead of a cell array
data = cell(1, length(files));
for i = 1:length(files)
data{i} = load_ifile(fileNames{i});
end
More Answers (0)
See Also
Categories
Find more on Digital Filter Design 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!