What is the code to plot several .dat files together?

3 次查看(过去 30 天)
I have 1000 .dat files and I want to plot graphs from them and save the results in .png format for all the files. How do we do that?

采纳的回答

KSSV
KSSV 2017-5-22
figure
hold on
datfiles = dir('*.dat');
for K = 1 : length(datfiles)
data = load(datfiles(k).name); %load just this file
% Plot the data depending on variables
end
  6 个评论
Arghadwip Paul
Arghadwip Paul 2017-5-22
编辑:Arghadwip Paul 2017-5-22
Thanks. But, I have already tried using natsortfiles,it did not work. I could not apply it properly as I'm new into Matlab. Can you please help me regarding how I should apply natsortfile function here to sort the files?
datfiles = dir('*.dat');
for k = 1 : length(datfiles)
data = load(datfiles(k).name);
h=figure;
scatter(data(:,1),data(:,2),50);
hold on;
quiver(data(:,1),data(:,2),data(:,4),data(:,5),0.3);
end
saveas(h,sprintf('fig%d.png',k));
hold off;
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by