Problem saving the figures

1 回表示 (過去 30 日間)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2020 年 1 月 21 日
回答済み: Walter Roberson 2020 年 1 月 21 日
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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by