필터 지우기
필터 지우기

Why does the SAVEAS command not append the correct file extension when the file name contains a period?

조회 수: 15 (최근 30일)
I want to save a figure to a file where the file name contains a period. I specify the file format, but the corresponding extension is not appended to the file name.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2009년 7월 21일
The command
SAVEAS(H,'FILENAME','FORMAT')
saves the figure specified by handle H to file name FILENAME. When FILENAME does not contain an extension (it has no periods in it), an extension corresponding to FORMAT is appended to the file name.
If FILENAME contains periods in it, MATLAB interprets this as an extension. The FORMAT option overrides whatever extension is specified by FILENAME, but the correct extension is not appended to FILENAME. If desired, the correct file extension must be explicitly defined in the filename.
For example, see the code below:
plot(1:10)
% the following creates a TIF file test1.tif
saveas(gcf, 'test1', 'tif')
% the following creates a TIF file test2.123
saveas(gcf, 'test2.123', 'tif')
% the follwoing creates a TIF file test3.123.tif
saveas(gcf, 'test3.123.tif', 'tif')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by