Problem in cropping the pdf image in matlab

I have the following pdf image generated by matlab code. When I save this image as ''pdf'', it comes up with huge white portion that I really want to remove. I just keep the image portion only. Please somebody help me to get that. Pl see the attachment for image in ''pdf''.

5 Comments

How are you creating the pdf file? Using code or the menu in the figure window?
Why you want to save pdf? Save it in jpg, png.
AVM
AVM on 12 Jun 2020
Edited: AVM on 12 Jun 2020
@Kssv: Thanks for your reply. Actually I had to attach this image in some places. I thought that as pdf image has good resolution, that's why I need this.
"I thought that as pdf image has good resolution"
Not necessarily. You can save high-resolution png and jpg files too. pdf is useful if you want vector image; however, in that case, I prefer eps over pdf.
@Ameer: Thanks for your information.

Sign in to comment.

 Accepted Answer

Try exportgraphics() in R2020a
t = linspace(0, 2*pi, 100);
r = linspace(0, 1, 100);
polarplot(t, r)
exportgraphics(gcf, 'test.pdf');
The output pdf file is attached.
For older releases
t = linspace(0, 2*pi, 100);
r = linspace(0, 1, 100);
polarplot(t, r)
export_fig(gcf, 'test.pdf');

8 Comments

@Ameer: Thanks. I have generated this image from system of equation by using matlab code. It was taking a long time to execute the code as there was so many expressions. Is there any way to crop this output image not by runng my code again as it is taking long time?
Do you have the .fig file? Or just the pdf file?
Yes. I have the .fig file. I just save that as pdf. But both of them I kept.
You can just open the fig file and while it is opened, run the code in my answer, It will work.
AVM
AVM on 12 Jun 2020
Edited: AVM on 12 Jun 2020
Thanks for your reply. By the way eps is working fine.
I am glad to be of help!
@Ameer: ''You can just open the fig file and while it is opened, run the code in my answer, It will work.''
Where the code has to be run? In command window or in script?
You can run it in command window or in a new script.

Sign in to comment.

More Answers (0)

Tags

Asked:

AVM
on 12 Jun 2020

Commented:

on 12 Jun 2020

Community Treasure Hunt

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

Start Hunting!