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

New to MATLAB?

How to make a simple plot (loading many files)?

Asked by Saturn's Ring

Saturn's Ring (view profile)

on 30 Nov 2012

I have a series of data files (*.dat). They each contain two columns of data (magnitude and time). I need to load in all of these files into Matlab, then plot magnitude vs time for all of these files, in one single plot. I'm not good with loop functions that's why I need some help. Thank you.

0 Comments

Saturn's Ring

Saturn's Ring (view profile)

Products

2 Answers

Answer by Azzi Abdelmalek

Azzi Abdelmalek (view profile)

on 30 Nov 2012
Accepted answer
f=struct2cell(dir('yourfolder/*.dat'));
name=f(1,:)
figure;
hold on
for k=1:numel(name)
v=dlmread(name{k});
plot(v(:,1),v(:,2))
end 

1 Comment

Saturn's Ring

Saturn's Ring (view profile)

on 30 Nov 2012

Perfect! Thanks!

Azzi Abdelmalek

Azzi Abdelmalek (view profile)

Answer by Walter Roberson

Walter Roberson (view profile)

on 30 Nov 2012

0 Comments

Walter Roberson

Walter Roberson (view profile)

Contact us