surfnorm function shows error

3 次查看(过去 30 天)
Hi,
I am trying to use surfnorm function to calculate the nor of 3D meshgrid. But the use of the functions shows error "Y and Z must be the same size as X." which I do not understand why!!
The size of X,Y,Z are the same even though the document in mathwork says it is possible to use meshgrid as an input as attached in the questions
x = linspace(-1,1,10);
y = x;
z = x;
[X,Y,Z]=meshgrid(x,y,z);
figure,
surfnorm(X,Y,Z);

采纳的回答

Ameer Hamza
Ameer Hamza 2020-11-15
编辑:Ameer Hamza 2020-11-15
X, Y, and Z must be 2D matrices. Z is a function of X and Y in this case. The following shows an example of how to use it properly
x = linspace(-1,1,10);
y = x;
[X,Y]=meshgrid(x,y);
Z = X+Y; % Z=X+Y is chosen as an example to show Z is a function of X and Y
figure,
surfnorm(X,Y,Z);
  2 个评论
Sara
Sara 2020-11-15
Thank you for your respnd,
I now understand the error,
Thank you.
Ameer Hamza
Ameer Hamza 2020-11-15
I am glad to be of help!!!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by