필터 지우기
필터 지우기

error using saveas in fig format

조회 수: 1 (최근 30일)
ET
ET 2024년 5월 8일
편집: ET 2024년 5월 10일
Hellow Dear,
I tried to save a figure using saveas in fig format and I got several error messages. Saving the same figure in other format such as jpg is fine.
% plot
for page = 1: num_page
if ci_end(page) > numel(screened_contact)
ci_end(page) = numel(screened_contact);
end
figure(page), clf
sgtitle(' Compare orig vs interpolated stim artifact in data pre-processing')
pageF = nrow_subp*ncol_subp*(page -1); % factor to compensate subplot# after page1
for ci = ci_begin(page) : ci_end(page)
subplot(nrow_subp, ncol_subp, ci-pageF), hold on
%grayColor = [.7 .7 .7];
plot(timevec, ref_EP(ci, :), 'k', "LineWidth", 1)
plot(timevec, prepro_EP(ci, :), 'r', "LineWidth", 1)
title( strjoin([num2str(ci) ', C' num2str(screened_contact(ci)) ', ' region(ci) ', ' region_abbrev(ci)]) )
plot([0 0], get(gca,'ylim'), 'k--', 'linewidth',1)
plot(get(gca,'xlim') ,[0 0], 'k--','linewidth', 1)
%yvalue = max([max(abs(ref_EP(ci,[1:900]))) max(abs(prepro_EP(ci,[1:900]))) ]);
%set(gca, 'ylim', [-1 1]* (yvalue+20))
%set(gca,'xtick',[-0.1 0 0.2 0.4])
%set(gca, 'xticklabels', [-0.1 0 0.2 0.4])
set(gca, 'xlim', [-0.1 0.4])
end
set(gcf, 'Position', get(0, 'Screensize'));
saveas(figure(1), [ char(output(1,:)) '\preprocessed_vs_ref_con' num2str(ci_begin(page)) '_to_' num2str(ci_end(page)) '.fig' ])
saveas(figure(1), [ char(output(1,:)) '\preprocessed_vs_ref_con' num2str(ci_begin(page)) '_to_' num2str(ci_end(page)) '.jpg' ])
close(1)
end

채택된 답변

Walter Roberson
Walter Roberson 2024년 5월 8일
Notice the error is shown as being on line 14 of savefig
Line 14 of the Mathworks supplied savefig gor R2022b is
% savefig(H,FILENAME,'compact') saves the figures identified by the graphics
So your problem is that you have a third-party savefig.m that is interfering with using saveas()
  댓글 수: 3
DGM
DGM 2024년 5월 9일
The error is not in the builtin axes class. It's in whatever file you named savefig.m, which is trying to take some unknown set of inputs and apply them in some unknown fashion to an axes object.
We can't see that file, so we don't know how it's mishandling the arguments it's given when called incorrectly.
Find the offending file and rename it so that it stops causing the problem.
which savefig -all % look for the file
/MATLAB/toolbox/matlab/graphics/objectsystem/savefig.m
If there is some other user created file called savefig.m, rename it.
ET
ET 2024년 5월 9일
편집: ET 2024년 5월 10일
Thanks, DGM
There are 3 diff savefig.m in 3 diff locations. After renaming 2 of them, the problem with saveas is gone.
>> which savefig -all
\MATLAB\Standford_script\Jeff_scripts\dannyGenScripts\ARTISTCode\savefig.m
\MATLAB\fieldtrip-20230215\external\lagextraction\savefig.m % Shadowed
\MATLAB\R2022b\toolbox\matlab\graphics\objectsystem\savefig.m % Shadowed

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by