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 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