To save plots without showing them on the screen
6 次查看(过去 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,
0 个评论
采纳的回答
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
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?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Bar Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!