save several plots in seperate files within a live script
Show older comments
hello there,
i have a live script which plots the results at its end. it creates a new figure and title and so on. now i want to save all the figures. the figures are being created in a function, cause there is a lot of different data, but more or less the same plot.
i have found 2 solutions so far, whcih sadly dont work.
the first solution i used had the problem that it doesnt save it according to the names. they just have no name and there are overwriting each other. another problem is, that out ofnowhere it gave me the error that the folder is incorrect. i made another folder for the plots and the folder does exist, matlab knows the folder i added it.
the 2nd solution gave me the following error message
3 Comments
Nathan Hardenberg
on 23 May 2023
You forgot to paste the error message from the second solution
Walter Roberson
on 23 May 2023
Accepted Answer
More Answers (1)
Andre
on 24 May 2023
1 Comment
Nathan Hardenberg
on 24 May 2023
Edited: Nathan Hardenberg
on 24 May 2023
Don't confuse Name and Title. The name is given to the figure when it is initialized (see following Code). The Title is the "Title" of the Axis-object, which is a child of the figure-object. If you would initialize all figures like seen below, the code from the solution1 should work. But by default no name is given to a figure.
fig1 = figure("Name", "myName");
fig1.Name
fig2 = figure;
fig2.Name
And nice to see that you found a way it works for you
Categories
Find more on Printing and Saving in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!