To save plots without showing them on the screen

4 次查看(过去 30 天)
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,

采纳的回答

Alberto Cuadra Lara
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 个评论
Alberto Cuadra Lara
编辑:Alberto Cuadra Lara 2022-5-4
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 2022-5-5
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.

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by