Reading and loading variable file names

9 次查看(过去 30 天)
Hello. Suppose I have a folder with a bunch of files that are for the most part something like A1,A2,A3... and another file that is like wow_100_wow_wow. The first thing I need to do is load the wow_ file thing but the number string(in this case 100) is arbitrary but changes and I'm not sure how to make it so it imports it. Within the the Wow_ file would be instructions for which of the A1,A2,.. files I need to carry out operations on. I keep looking at stuff but I can't find something that would allow me to save the numbers in the A files and read them appropriately

采纳的回答

Iain
Iain 2013-8-22
Sounds like you need a combination of reading filenames, and generating filenames:
A = dir('D:\mydatahere\Wow*.mat');
A is a structure containing the filename of every mat file, starting with Wow, in that folder. Assuming that there is only one:
wowfile = ['D:\mydatahere\' A.name] %will put the name of that file into wowfile. Read wowfile by the appropriate means.
A_filename = ['A' num2str(an_A_file_to_read) '.mat'];
Change .mat to whatever extension you need.

更多回答(1 个)

Walter Roberson
Walter Roberson 2013-8-22

类别

Help CenterFile Exchange 中查找有关 Install Products 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by