How do I save a Figure with a Filename based on it's contents?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I've written some code to extract data from an excel spreadsheet into a .mat file for further processing. For each .mat file, I want to produce a corresponding figure showing the data that it contains.
I've managed to automatically name the .mat file using the start and end dates of the data that it contains, and I want to name the figure in the same way. However I get an error message when I use the following code:
FileName = ["DMFlowData", StartDate, EndDate]
Filename = strjoin(FileName)
print (fig, FileName,'-fillpage','-dpdf')
'The messages that I get are:
'Error in checkArgsForHandleToPrint'
Handle input argument contains nonhandle values.
Adding ' ' either side of my variable FileName just results in a figure saved as FileName.pdf, not the dates. I've omitted the code used to create the figure.
Thanks!
0 comentarios
Respuestas (1)
Steven Lord
el 8 de En. de 2020
What does the variable named fig contain? I think you intend for it to be the fig input argument listed in the Description section of the print documentation page, but it contains a handle to something that's not a figure object or Simulink block diagram.
Maybe it's an axes handle, in which case you should instead print the figure that contains it? So in the example below you'd print using f (the figure) rather than ax (the axes.)
ax = axes
f = ancestor(ax, 'figure')
Ver también
Categorías
Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!