Reading file name in a loop.
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I've a Matlab-File for a specific calculation which is placed in a Folder 'A'.
Folder 'A' contains seven more Folder 'B1,B2,...,B7' with different variants. Each folder 'B1,...,B7' contains 45 excell files.
Actually I'm loading a specific excell file with this code:
addpath B1
filename = 'VAR2_D302_N100000_BP5.xlsx'
num = xlsread(filename);
and have to change every time the addpath name if I want to jump in another folder or the filename if I want to select another excell fle.
Is there any other way to do this. I mean how can I automatize this process?
I was thinking of a loop which selects the folder and excell file in need by specifying variables which output the name of my files.
% Example with two files in a Folder 'B1'
% VAR2_D302_N100000_BP5.xlsx
% VAR2_D302_N100000_BP6.xlsx
X=2;
for i=1:X
addpath B1
filename = 'VAR2_D302_N100000_BPX.xlsx' % This will not work. How can I tell matlab that the 'i' is changing?
end
num = xlsread(filename);
Thank you.
0 Kommentare
Antworten (1)
KSSV
am 17 Nov. 2017
This question is discussed to death.....A search in google and mathworks will give you lot os links.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Search Path finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!