error using savefig: too many input arguments

5 views (last 30 days)
Hello,
For a while, I've been getting the error: error using savefig: too many input arguments when I try to save a figure in .fig format, using either saveas or savefig functions. It appears even when I try to save the figure manually from the figure window.
This happens to me in version R2022b and R2021a, used on different PCs and even when I run programs that previously worked well. The syntax of the functions I use should be good, because it worked before. I don't understand if it could be a problem with the version of Matlab used (I don't think so because other colleagues with the same version do not receive the same error) or with my personal configuration, perhaps I have changed something without realizing it.
With all this I cannot save figures to edit them later.
Can anyone give me an idea how to solve it?
Thank you,
Jose Luis

Accepted Answer

Dheeraj
Dheeraj on 25 Jul 2024
Hi JOSE LUIS GOMEZ AMO,
I understand that you are trying to save a figure to disk, but even when trying to save it from the figure by clicking File -> Save, you receive the error message "Error using save: Too many input arguments".
The manual save process, as well as the functions "saveas" and "savefig" internally use a function called "save". This appears to be the source of the error message.
It is possible that the function "save" has been inadvertently broken or overloaded. For instance, there might be a custom function named "save" on your path.
As an initial troubleshooting step, please enter the following command into the MATLAB Command Window:
which save -all
The first line of the output should normally be something like: "built-in (<path>\MATLAB\R2022b\toolbox\matlab\general\save)".
If it is a custom function instead, either rename the custom function or remove it from the MATLAB path. Then restart MATLAB (saving and loading your workspace if necessary) and try saving a figure again.
Thank you.

More Answers (1)

JOSE LUIS GOMEZ AMO
JOSE LUIS GOMEZ AMO on 25 Jul 2024
Thank you so much,
It wasn't exactly the "save" function, because it could save other formats. However it was a "savefig.m" function from an old version of Matlab (around 2011). It was in an old work directory of mine that I had added to the current work path. I do not understand why.
Since I have the working directories synchronized on both PCs, I had the same problem on both. I have removed that directory from the path, and everything works again.
Thank you very much
José Luis

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!