Skip to content

Instantly share code, notes, and snippets.

@gugarosa
Created August 30, 2019 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gugarosa/f784d31eda34d139146da8fbbf9dcee2 to your computer and use it in GitHub Desktop.
Save gugarosa/f784d31eda34d139146da8fbbf9dcee2 to your computer and use it in GitHub Desktop.
It creates a 3D plot of a pre-defined mathematical function.
% Function to be plotted
z = @(x,y) (sin(x) * sqrt(x)) * (sin(y) * sqrt(y));
% Plots the function
h = fsurf(z,[0 10]);
% Defines some attributes on its positioning and brightness
camlight(110,70)
brighten(0.7)
h.EdgeColor = 'none';
h.AmbientStrength = 0.6;
% Defines its color map
colormap jet;
% Creates the box around the plot
a = gca;
a.Box = 'on';
a.BoxStyle = 'full';
% Defines labels and title
xlabel('x', 'FontWeight', 'bold', 'FontSize', 14);
ylabel('y', 'FontWeight', 'bold', 'FontSize', 14);
zlabel('z', 'FontWeight', 'bold', 'FontSize', 14);
title('f(x, y) = sin(x) * sqrt(x) * sin(y) * sqrt(y)');
% If necessary, re-render amount of desired ticks
a.XTick = 0:5:10;
a.YTick = 0:5:10;
a.ZTick = -6:6:6;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment