MATLAB function to make 3D plot

조회 수: 2 (최근 30일)
John
John 2023년 8월 28일
답변: Riya 2023년 8월 31일
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

답변 (1개)

Riya
Riya 2023년 8월 31일
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!

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by