Effacer les filtres
Effacer les filtres

'saveas' does not overwrite existing image file

32 vues (au cours des 30 derniers jours)
Julia
Julia le 6 Nov 2018
Commenté : Julia le 7 Nov 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 commentaire
Julia
Julia le 7 Nov 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?

Connectez-vous pour commenter.

Réponse acceptée

Stephan
Stephan le 7 Nov 2018
Modifié(e) : Stephan le 7 Nov 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 commentaire
Julia
Julia le 7 Nov 2018
Hi Stephan,
Thank you very much! That works.
Best Julia

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Printing and Saving dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by