I want to plot a function in 3D and to export as high quality
29 次查看(过去 30 天)
显示 更早的评论
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');
0 个评论
回答(1 个)
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))
2 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!