Borrar filtros
Borrar filtros

'saveas' does not overwrite existing image file

32 visualizaciones (últimos 30 días)
Julia
Julia el 6 de Nov. de 2018
Comentada: Julia el 7 de Nov. de 2018
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 comentario
Julia
Julia el 7 de Nov. de 2018
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?

Iniciar sesión para comentar.

Respuesta aceptada

Stephan
Stephan el 7 de Nov. de 2018
Editada: Stephan el 7 de Nov. de 2018
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
  1 comentario
Julia
Julia el 7 de Nov. de 2018
Hi Stephan,
Thank you very much! That works.
Best Julia

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by