Image file saving location

조회 수: 6 (최근 30일)
형준 이
형준 이 2022년 5월 19일
댓글: 형준 이 2022년 5월 19일
my code ↓
for i = 1:5
h = imagesc(X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = ['Image', num2str(i)];
print(fname, '-djpeg');
end
How do I save the image file to folder 'C:\Users\leehj\Desktop\aaa' ?

채택된 답변

Walter Roberson
Walter Roberson 2022년 5월 19일
outdir = 'C:\Users\leehj\Desktop\aaa';
for i = 1:5
h = imagesc(X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = fullfile(outdir, ['Image', num2str(i)]);
print(fname, '-djpeg');
end
  댓글 수: 2
Walter Roberson
Walter Roberson 2022년 5월 19일
편집: Walter Roberson 2022년 5월 19일
Note: with modern MATLAB, you should consider using exportgraphics() .
Also you should probably include the file extension.
There are also nicer ways to construct the name,
outdir = "C:\Users\leehj\Desktop\aaa";
ax = gca;
for i = 1:5
imagesc(ax, X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = fullfile(outdir, "Image" + i + ".jpg");
exportgraphics(ax, fname);
end
형준 이
형준 이 2022년 5월 19일
thank you ver much :- )

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

추가 답변 (1개)

KSSV
KSSV 2022년 5월 19일
thepath = 'C:\Users\leehj\Desktop\aaa\' ;
for i = 1:5
h = imagesc(X, Y, Z(:,:,i)); xlim([-2 2]); ylim([-1 1]);
fname = [thepath,'Image', num2str(i)];
print(fname, '-djpeg');
end
  댓글 수: 1
형준 이
형준 이 2022년 5월 19일
thank you ver much :- )

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

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by