Problem saving the figures

1 次查看(过去 30 天)
I need to save figures produced by a function. The figures are open in matlab Iused this code:
save_jpegs='C:\Users\jpegs';
save_figs='C:\Users\figs';
number_of_figures=findobj('type','figure');
for i=1:length(number_of_figures)
saveas(figure(i),fullfile(save_jpegs,[ num2str(i) '_' figures(i).Name '.jpeg']));
saveas(figure(i),fullfile(save_figs,[ num2str(i) '_' figures(i).Name]));
end
I recieve thie error:
Undefined variable "figures" or class "figures".
any idea why?

采纳的回答

Walter Roberson
Walter Roberson 2020-1-21
As outside observers, we have no reason to expect that a variable named figures exists.
save_jpegs = 'C:\Users\jpegs';
save_figs = 'C:\Users\figs';
figures = findobj('type','figure');
for i = 1 : length(figures)
saveas(figures(i), fullfile(save_jpegs,[ num2str(i) '_' figures(i).Name '.jpeg']));
saveas(figures(i), fullfile(save_figs,[ num2str(i) '_' figures(i).Name]));
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by