필터 지우기
필터 지우기

How to loop over multiple data and save the plot?

조회 수: 3 (최근 30일)
Ritesh Chandra Tewari
Ritesh Chandra Tewari 2021년 7월 26일
답변: Yongjian Feng 2021년 7월 26일
I am using matlab online. I have 2000 dat files as data. Whenever I run the code, the folder appears and I have to manually select the data file. I want to loop over all the data and automatically save the plot. How to do that.

답변 (1개)

Yongjian Feng
Yongjian Feng 2021년 7월 26일
Try this:
files = dir("*.mat");
for i=1:length(files)
clf;
file = files(i);
load(file.name);
plot(x, y);
[~, fname, ~] = fileparts(file.name);
outfile = [fname '.png'];
saveas(gcf, outfile);
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by