Saving a figure as a png with a specific name from predefined variable

I would like to save a figure as a png with the name as a value that I had already predefined in the code. The code below is not calling that value. My variable that I would like to use as the name of the png is defined as plottitle.
I keep getting an error that says invalid filename.
plottitle is my variable
saveas(gcf,plottitle.bmp)
Output: Error using saveas (line 96)
Invalid filename.

1 commentaire

"Invaluid filename" is a surprising message. If plottitle is a string, which contains the name of the file, plottitle.bmp is interpreted as the access of the field bmp of a struct. Then the error message should be different.
It is recommended to post running examples. As soon as you show how plottitle is defined, the actual problem would be clear.

Connectez-vous pour commenter.

 Réponse acceptée

Jan
Jan le 22 Jan 2019
Modifié(e) : Jan le 22 Jan 2019
With some guessing:
saveas(gcf, [plottitle, '.bmp'])

1 commentaire

When I input that code I get the following error
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
Error in Uniform_Plots (line 61)
saveas(gcf, [plottitle, '.bmp'])
However the following code does work:
saveas(gcf,p.Title{1,1},'bmp')
Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Analysis dans Centre d'aide et File Exchange

Produits

Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by