MATLAB Answers


Is there a way of creating a code so every time you save a figure as .mat it automatically also saves it as .bmp?

Asked by Serena Campbell on 19 Apr 2019
Latest activity Answered by Cris LaPierre on 20 Apr 2019
I am running various code, and I dont want to save the figure every time (hence I don't want to incorporate it into my functions or codes)
I was just wondering if there was a way of setting matlab up so that every time i save a file as .mat manually in the figure window - that it also saves the figure simultaniouly in another format (fx .bmp)
currently I have to go in manually and save the file twice which is time consuming.


Sign in to comment.




1 Answer

Answer by Cris LaPierre on 20 Apr 2019

There is code you can add to your script/function so that once a figure has been created, it will save it.
This is done with the print command. Use the formattype argument to specify the file format to create. There are a couple of bmp options shown in the table here.
See this example for saving a barplot as a png. Additional examples follow it.


Sign in to comment.