필터 지우기
필터 지우기

Reading and loading variable file names

조회 수: 3 (최근 30일)
Bernard
Bernard 2013년 8월 22일
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