To save plots without showing them on the screen

6 visualizaciones (últimos 30 días)
Hello.
The following code is supposed to plot a variable and save it in an EXCEL sheet. I am running a series of codes for biomechanical analysis of gait with about 500 plots that must be saved in one EXCEL sheet. It means for each sheet, I have to wait for a plot and save this plot in the EXCEL sheet. It is time taking and needs memory becasue MATLAB has to show 500 plots on the screen and save them in the EXCELL document!
figure;
for k=1:length(mN(:,1))
plot(mN(k,:),'g')
hold on
end
plot(mN,'b','linewidth',2)
title ('Healthy_Right');
writetable(table(ccc, ddd), 'Biomechanics_PT_Pre','WriteVariableNames', true);
xlswritefig(gcf, 'Biomechanics_PT_Pre', 'CV_BOSlenRRLL', 'B20');
Using %, I deactivated the plot command. However, MATLAB saved the plots in the EXCEL sheet without any curves!!! As an amateur, I asked MATLAB to close the plots (using the "close all" command) after saving the plot in the EXCEL sheet but I know it is not a good way. Is there any way to directly save the plots in the EXCEL document without showing them on the screen? Would you please assist me to improve the speed of this process? Please assist me with this issue.
Sincerely,

Respuesta aceptada

Alberto Cuadra Lara
Alberto Cuadra Lara el 2 de Mayo de 2022
Hi Vahid,
Just set the property 'visible' of the object figure to 'off'.
f = figure('visible','off');
hold on
for k=1:length(mN(:,1))
plot(mN(k,:),'g')
end
plot(mN,'b','linewidth',2)
title ('Healthy_Right');
writetable(table(ccc, ddd), 'Biomechanics_PT_Pre','WriteVariableNames', true);
xlswritefig(gcf, 'Biomechanics_PT_Pre', 'CV_BOSlenRRLL', 'B20');
  3 comentarios
Alberto Cuadra Lara
Alberto Cuadra Lara el 4 de Mayo de 2022
Editada: Alberto Cuadra Lara el 4 de Mayo de 2022
Hi Vahid,
You are not using the same function. "xlswrite" is not recommended. Use writetable as in the first case. Btw, "xlswritefig" is a function you created, right?
Vahid Esmaeili
Vahid Esmaeili el 5 de Mayo de 2022
Hello Alberto,
Thank you for the reply. I will try writetable and I will inform you how it works.
I found the "xlswritefig" on MathWorks.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Bar Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by