Effacer les filtres
Effacer les filtres

Reading and loading variable file names

3 vues (au cours des 30 derniers jours)
Bernard
Bernard le 22 Août 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

Réponse acceptée

Iain
Iain le 22 Août 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.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 22 Août 2013

Catégories

En savoir plus sur Install Products dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by