Filter löschen
Filter löschen

error using saveas in fig format

1 Ansicht (letzte 30 Tage)
ET
ET am 8 Mai 2024
Bearbeitet: ET am 10 Mai 2024
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

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 8 Mai 2024
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 Kommentare
DGM
DGM am 9 Mai 2024
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 am 9 Mai 2024
Bearbeitet: ET am 10 Mai 2024
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Printing and Saving finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by