'saveas' does not overwrite existing image file

27 次查看(过去 30 天)
Hello!
My script plots some points on an image ('whatever.tif') and should subsequently save the resulting figure using 'saveas' (as 'whatever_points.tif'). This works fine if there is no file 'whatever_points.tif' in the output folder yet. If 'whatever_points.tif' exists already in this folder, nothing seems to happen, i. e. the figure is not saved. I would, however, like the script to overwrite the preexisting figure if there is one. I thought this was the default but it clearly doesn't seem to be?
This is what I use for saving:
filename_image = 'D:\somefolder\whatever.tif'
figure_name = [filename_image(1:end-4), '_points'];
figure_format = filename_image(end-2:end);
saveas(gcf,figure_name, figure_format);
Thanks for your help!
  1 个评论
Julia
Julia 2018-11-7
Sorry, I just found that it does actually overwrite the file. However, on Windows 8.1 the date of the last modification date of this file is not updated so you can't easily see when the file was last modified. Is there another way of obtaining this information?

请先登录,再进行评论。

采纳的回答

Stephan
Stephan 2018-11-7
编辑:Stephan 2018-11-7
Hi,
see this contribution from Mathworks Support Team:
>> info = dir('Untitled.m')
info =
struct with fields:
name: 'Untitled.m'
folder: 'W:\Matlab\Projekte'
date: '10-Jul-2018 16:32:29'
bytes: 65
isdir: 0
datenum: 7.3725e+05
The date field in this structure is the last modification date.
Best regards
Stephan

更多回答(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