figure to pdf but without the displaying it in the "figure-window"?

8 views (last 30 days)
I have this code where I want to make a pdf from some plotted data. But I dont want the display "figure window" to show. I just want it to only save the pdf and now show the plot. Right now I'm using: close(handles.figure1) to remove it. But I would like to save the computation time of presenting the plot, just to close it right after because im only interested in saving it in a pdf file.
Here is my code:
Create figure
handles.figure1 = figure('PaperOrientation','landscape','PaperType','A3',...
'PaperSize',[41.980612 29.703776],...
'Color',[1 1 1]);
% Create axes
axes1 = axes('Parent',handles.figure1,...
'Position',[0.0697916666666667 0.11 0.916145833333332 0.815]);
% Create area
% Create xlabel
xlabel('Antal Slag [-]');
% Create title
% Create ylabel
ylabel('Fald Højde [m]');
% Uncomment the following line to preserve the X-limits of the axes
xlim(axes1,[4 80]);
%ylim(axes1,[0 1.05]);
% Set the remaining axes properties
hA = gca;
hA.XAxis.MinorTickValues = 5:2:79;
% Create textbox
[0.73 0.697616060225847 0.3 0.198243412797992],...
'String',{['Dimensioner: ' num2str(Dim*100) 'x' num2str(Dim*100) ' cm'],['Pæle længde:' num2str(L) ' m'],['Faldlod: ' num2str(vaegt) ' kN'],['Bæreevne (Rcd): ' num2str(Rcd) ' kN']},...
[FileName,PathName] = uiputfile('test.pdf','Save Print');
print(handles.figure1, '-fillpage', '-dpdf', fullfile(PathName, FileName))
So to clarify my question, how do I make a pdf without having the plot appear in the "figure-window"?
Is there a workaround other than:
f = figure('visible', 'off');

Accepted Answer

ANKUR KUMAR on 5 Dec 2017
Use print or saveas function to save a plot/figure. To close your figure window automatically after saving the plot in pdf.jpeg, then just write cab at the end of the program. It automatically closes all figure windows.
Just copy this function and paste it in your home directory. After this, whenever you want to close all figure window, just write cab

More Answers (0)

Community Treasure Hunt

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

Start Hunting!