error using saveas in fig format
조회 수: 1 (최근 30일)
이전 댓글 표시
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1690416/image.jpeg)
댓글 수: 0
채택된 답변
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
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
If there is some other user created file called savefig.m, rename it.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Printing and Saving에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!