Run multiple data files from a directory using function in .m file
Mostra commenti meno recenti
I am a beginner to coding, so I need clear explanations of any possible answers to my question.
I have a folder (labeled as 'FolderName' in the script below) that is full of many subfolders with names like "2YYY-MM-DD". Each of those "YYYY-MM-DD" subfolders contain a data file with the extention ".eod". I have a function in a .m file (labeled as 'function_name' in the script below). What I am wanting to do is run the 'function_name' script for each of those .eod files. The 'function_name' script creates a few plots, and I want each of those plots to be saved into those "YYYY-MM-DD" original folders. Instead of having to run .eod file by file, I want it done in one swoop. This code below is not spitting back errors, but it is also not saving those plots in those respective folders. The 'function_name' script runs perfectly if I simply do the command line "function_name('data_file_name.eod')".
Help would be greatly appreciated!
clear all
close all
parent = '\FolderName';
folders = dir([parent, '\2*']);
folders = char({folders.name});
fileNames = {};
count = 1;
for i = folders
files = dir([parent, i, '\*.eod']);
fileNames(count) = {files.name};
count = count + 1;
end
fileNames = string(fileNames);
for i = fileNames
function_name(char(i));
end
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Get Started with MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!