Problem with the latex eps format
23 次查看(过去 30 天)
显示 更早的评论
Hello friends, I would like you to help me, I am using the 2020 trial version of matlab, I want to make a report in latex but when importing the graphics in .eps format in the latex document they come out pixelated. I would like you to give me some help since when I used matlab 2016 the graphs turned out well.
matlab codeph:
num=[1 5 -5 0 19]
den=[1 5 1 1 1 -4]
f=tf(num,den)
rlocus(f)
1 个评论
Vladimir Sovkov
2020-10-4
It is strange but you are right indeed. In the matlab window, the curves look to be vectorized, but after exporting to eps or svg they become pixelated. It never happened when I created plots with the plot command, etc. On the other hand, eps files are allowed to contain bitmap images, and you can insert them into the latex document anyway. I have no idea what else can be done.
采纳的回答
Bjorn Gustavsson
2020-10-4
When you write to postscript-format matlab (still) makes "clever" choises about how to write the file. Try to enforce vectorized format by invoking the painters renderer:
print -depsc2 -painters Your_file-01.eps
or:
print('-depsc2','-painters','Your_file-01.eps')
Otherwise print might use the -opengl renderer.
HTH
4 个评论
Bjorn Gustavsson
2020-10-7
You have to do some work, I'm afraid. In my long-work-scripts I typically have snippets something like this:
%At the top of the script I have define directives-variables
print_figs = 1; % or zero to not plot figures, or even an array of ones and zeros...
% Then I typically have a run-index saved in a project-specific mat-file:
load('thisproject.mat',run_idx)
run_idx = run_idx + 1; % that I increment
save('thisproject.mat','run_idx','-append')
% Then in the script for each figure I have:
if print_figs
print('-depsc2','-painters',sprintf('Figures/this-fig-name-%03d.eps',run_idx))
end
That becomes a simple process of copy and paste when modifying, so not that bothersome.
You could write yourself a function that does something similar, perhaps something like this:
function thatwentok = print_another_eps_figure()
load('fignumber.mat',idx)
idx = idx+1;
save('fignumber.mat','idx')
print('-depsc2','-painters',sprintf('next-fig-%04d.eps',idx))
end
Then you'd only have to run that function and the figures will be saves with incremental names. But this convenience, I think, will not benefit you that much in the long run because one thing you will want to do is to re-do your figures, and that is very much helped by having scripts/functions that you can run and reproducibly repeat the tasks. But, maybe it is worth it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!