MATLAB function to make 3D plot

20 views (last 30 days)
John
John on 28 Aug 2023
Answered: Riya on 31 Aug 2023
Please, what MATLAB function can I use to make this 3D plot.
Reference: Local Fractional Laplace Variational Iteration Method for Solving Linear Partial Differential Equations with Local Fractional Derivative

Answers (1)

Riya
Riya on 31 Aug 2023
Hello John
As per my understanding, you want to make a 3D plot similar to the one you attached.
Please know that in this case, you may use the “surf” function in MATLAB. The "surf function is generally used to create 3D surface plots. It visualizes a matrix or grid of heights as a surface with different colors to represent the height values.
Following is the basic syntax for using the "surf" function:
surf(X, Y, Z)
Here, ‘X and Y are matrices or vectors representing the x and y coordinates of the points in the grid.
Z is a matrix representing the corresponding height values at each (x, y) coordinate.
Below is a sample code that demonstrates how to create a simple surface plot using the surf function:
% Create x and y coordinates
x = linspace(-5, 5, 100);
y = linspace(-5, 5, 100);
[X, Y] = meshgrid(x, y);
% Define the height function
Z = sin(sqrt(X.^2 + Y.^2)) ./ (sqrt(X.^2 + Y.^2));
% Create the surface plot
surf(X, Y, Z)
In this example, X and Y; are created using the meshgrid function to define the coordinates of the points in the grid. Z is defined as a height function based on the x and y coordinates. Finally, the surf function is used to create the surface plot.
You can also customize the appearance of the surface plot by specifying additional parameters, such as colormap, shading, lighting, and more.
Please refer the following MathWorks Documentation for more details on the various options available with the surf function:
https://in.mathworks.com/help/matlab/ref/surf.html
I hope this helps!

Community Treasure Hunt

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

Start Hunting!