I want to plot a function in 3D and to export as high quality
26 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Sulaymon Eshkabilov
le 1 Jan 2022
(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 commentaires
Voir également
Catégories
En savoir plus sur Colormaps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!