필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
Arghadwip Paul
Arghadwip Paul 2017년 5월 22일
댓글: Huzaif Rahim 2020년 7월 23일
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?
  댓글 수: 1
Huzaif Rahim
Huzaif Rahim 2020년 7월 23일
I have the same question.
The answer down here are not working for me.
@KSSV

댓글을 달려면 로그인하십시오.

채택된 답변

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
KSSV
KSSV 2017년 5월 22일
You can try this file exchange function by Stephen Cobeldick:
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