Azzera filtri
Azzera filtri

Reading and loading variable file names

3 visualizzazioni (ultimi 30 giorni)
Bernard
Bernard il 22 Ago 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

Risposta accettata

Iain
Iain il 22 Ago 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.

Più risposte (1)

Walter Roberson
Walter Roberson il 22 Ago 2013

Categorie

Scopri di più su Install Products in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by