load(FILENAME), loading files in a loop

7 ビュー (過去 30 日間)
Igor
Igor 2015 年 9 月 27 日
編集済み: Igor 2015 年 9 月 27 日
Hello. I have a bunch of .txt files named as follows:
file1aacd.txt
file2klmn.txt
file3ouio.txt
file4asff.txt etc...
So as you can see, the first part of the file name is neatly ordered, while the last part of the file name is a set of random characters that are irrelevant to me right now and are preventing me from being able to create a for loop.
So, I'd like to create a for loop that will use the load function to go through all the files, but I don't know how to make MATLAB ignore the last part of the file name.
So, I need something like this:
for X = 1:50;
...
...
B = load(fileX<ignore_the_next_4_characters_of_file_name>.txt);
% do some calculations;
end

回答 (1 件)

Image Analyst
Image Analyst 2015 年 9 月 27 日
See the FAQ for code samples on constructing a filename, or getting already existing ones, and processing all the files in a loop:

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by