Filter löschen
Filter löschen

Reading and loading variable file names

3 Ansichten (letzte 30 Tage)
Bernard
Bernard am 22 Aug. 2013
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

Akzeptierte Antwort

Iain
Iain am 22 Aug. 2013
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.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 22 Aug. 2013

Kategorien

Mehr zu Install Products finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by