MATLAB Answers

Thar
0

read-open many files

Asked by Thar
on 10 Jul 2015
Latest activity Commented on by Thar
on 11 Jul 2015
Hi all!
I have 200 files with name day_0012014 until day_2002014. Each file has 3 columns. I want to plot first and third columns. What can i do?
Thanks...

  0 Comments

Sign in to comment.

1 Answer

Answer by Azzi Abdelmalek
on 10 Jul 2015
Edited by Azzi Abdelmalek
on 10 Jul 2015

You didn't specify the type of files (text file or Excell or ...). Suppose they are text files
for k=1:200
FileName=sprintf('day_%03g2014.txt',k)
data{k}=dlmread(Filename)
end
Now you can access to each matrix
figure
hold on
for k=1:numel(data)
c1=data{k}(:,1)
c3=data{k}(:,3)
plot(c1,c3)
end
hold off

  1 Comment

Thar
on 11 Jul 2015
my files are txt.
all these files are in my desktop in a file with name measurments.
I wrote the path in the filename like
FileName=sprintf('C:\......Desctop\measurments\day_%03g2014.txt',k)
but it has wrong:
Undefined function or variable 'Filename'.
Thank you

Sign in to comment.