To save plots without showing them on the screen

조회 수: 3 (최근 30일)
Vahid Esmaeili
Vahid Esmaeili 2022년 5월 2일
댓글: Vahid Esmaeili 2022년 5월 5일
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
Alberto Cuadra Lara 2022년 5월 2일
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일
편집: 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개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by