Borrar filtros
Borrar filtros

error using saveas in fig format

1 visualización (últimos 30 días)
ET
ET el 8 de Mayo de 2024
Editada: ET el 10 de Mayo de 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

Respuesta aceptada

Walter Roberson
Walter Roberson el 8 de Mayo de 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 comentarios
DGM
DGM el 9 de Mayo de 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 el 9 de Mayo de 2024
Editada: ET el 10 de Mayo de 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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by