Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
make a list of input

Subject: make a list of input

From: edward kabanyas

Date: 23 Jul, 2011 06:49:09

Message: 1 of 1

Hi all,

Again, I would like to ask a question about matlab.

I analyze many input files and so far I write my matlab code in the same folder with the data. I make a list of my input as (I am working in windows machine):

dos(' dir /b *.txt> list');

fid=fopen('list','r');
n=0;
while ~feof(fid)
    n=n+1;
    fname{n}=fgetl(fid);
     
end
fclose(fid);

It is then very simple to take the input file from the list (fname) by using any open file command.

Now, I want to separate the matlab code and data, the data in one folder and the matlab code in another folder. I use the following code:


 dos('dir /b ..\data\ *.txt >list')

The output is:
data1.txt
data2.txt
...
index.html. I also get a comment as

File Not Found

ans =

     1

But I get a list of input as mentioned above with index.html at the end..

What I need is:
..\data\data1.txt
..\data\data2.txt
....
..\data\datan.txt

Do you have any experience with this problem ? I hope you could share with me. Thanks for your help.

Edward

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us