필터 지우기
필터 지우기

I want to plot a function in 3D and to export as high quality

조회 수: 15 (최근 30일)
student_md
student_md 2022년 1월 1일
댓글: Torsten 2022년 1월 2일
I have a function as follows:
I want to plot the function in 3D and then I want to export the figure with high quality (such as .eps or .pdf)
First Question: I defined the function as an anonymous function (func=@(x,t) ....) and I use command fsurf. What are the best options? (Should I use meshgrid )
Second Question: When I save the figure, I get a .eps file with a huge size (10 MB) using saveas(gcf, 'figure.eps', 'epsc');
What do you suggest to the reduce size of the figure?
close all;
clc;
clear all;
figure (1)
func=@(x,t) (16/3).*(12.*((-4)+4.*exp(1).^(8.*((-1/16)+(-2).*t+x))).^(-1)+(-4)*((-1/16)+(-2).*t+x));
fsurf(@(x,t) func(x,t),[-1 1 0 1],'ShowContours','on');
set(gcf,'renderer','Painters');
set(gcf, 'PaperPositionMode', 'auto')
saveas(gcf, 'figure.eps', 'epsc');

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2022년 1월 1일
(1) To have a better resolution of the plotted data and control over the calc resolution, it is better to employ meshgrid()
(2) To have a compact exported image, it is better to employ exportgraphics for about 73 times more efficient.
func=@(x,t)(16/3).*(12.*((-4)+4.*exp(1).^(8.*((-1/16)+(-2).*t+x))).^(-1)+(-4)*((-1/16)+(-2).*t+x));
[X, T] = meshgrid(linspace(-1,1), linspace(0,1));
F=func(X,T);
meshc(X,T,F);
set(gcf,'renderer','Painters');
set(gcf, 'PaperPositionMode', 'auto')
saveas(gcf, 'Fig1.eps', 'epsc');
S1=dir('Fig1.eps');
S1_Size=S1.bytes;
H = figure;
meshc(X,T,F);
exportgraphics(H,'Fig2.eps')
S2=dir('Fig2.eps');
S2_Size=S2.bytes;
fprintf('The size compactness: %d times \n', round(S1_Size/S2_Size))
The size compactness: 73 times
  댓글 수: 2
student_md
student_md 2022년 1월 2일
편집: student_md 2022년 1월 2일
Thank you.
In your suggestions, Fig.1 has high quality, but Fig2 doesn't have high quality. When I zoom in, it is pixelated such as bitmap format. Please see the result of Fig2 as follows.
I expect the file to be high quality and with as low file size as possible. How can we achieve this? Could you share some alternatives? (may be we export .pdf file)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by