MATLAB Answers

how do use patch in the background?

12 views (last 30 days)
Liang Zhan
Liang Zhan on 8 Apr 2011
I know matlab has patch function, which is patch(X,Y,Z,C) creates a patch in 3-D coordinates. If the coordinate data does not define closed polygons, patch closes the polygons. The data can define concave or intersecting polygons. However, if the edges of an individual patch face intersect themselves, the resulting face might be only partly filled. In that case, it is better to divide the face into smaller polygons.
I can use it to plot my figure normally, but the question is I need to do this work in the background (something like use patch to plot the figure(no display), then save the figure as jpg or eps in the background, then only display the jpg or eps.)
can anyone help me? Thanks,
LZ

Answers (1)

Liang Zhan
Liang Zhan on 8 Apr 2011
I run the code in unix background, and the main code is:
h=figure('Visible','off');
for i=1:256
for j=1:256
patch(XX, YY, ZZ,C,'LineStyle', 'none');
end
end
saveas(h,'figure_test_no_display.jpg');
then it come out a very long error message, which I can not post here.
  14 Comments
Liang Zhan
Liang Zhan on 8 Apr 2011
Wow~, it works very well, thanks a lot for your suggestion. It solved me a big problem, appreciate!!!

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!

Translated by