How do I load the names of all files from a directory so they can be run in order as part of a function?

3 Ansichten (letzte 30 Tage)
Hey peeps,
I'm new to MatLab and I'm lost. I'm attempting to load and create a cell that contains all the .txt files in a folder in order by name (x01.txt, x02.txt, x03.txt.......x10.txt, however long).
I'm trying to frame this as part of an answer to a prompt.
Once all are loaded, then I'm hoping to run those files in that cell as a function of another script. I realize this may not be the most efficient way of doing this, but it is simply how this task must get done.
EDIT: I cannot load all the files, they are too big. I just need a cell array that can be read so the files can be loaded and processed using 'my_script_that_totally_works.m' one at a time.
I also can't use uigetdir, because this has to be done on a remote linux computer withot a gui
%%selecting the files to be loaded
clc
clear
clear all
addpath(genpath('Y:\MYDIRECTORY\*.txt'));
prompt = 'Enter file directory (mmddyyyy_bin)';
filedirectory=input(prompt, 's')
files=dir('filedirectory\*.txt')
for i=1:length(files)
eval(['load' files(i).name'-ascii']);
end
%%The loop to run through all the files. The number of files are never the same, must be independant of length
for i=1:length(files)
my_script_that_totally_works.m
end

Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by