Surfplot with surface color as a function of gradient (slope)

31 visualizaciones (últimos 30 días)
Hi,
I would like to plot a surface plot, where i would like to vary the surface color based on the gradient of z instead of its magnitude. Is there a way to do it?
Thanks and Regards

Respuesta aceptada

Karthik  Vemireddy
Karthik Vemireddy el 8 de Ag. de 2018
Editada: Karthik Vemireddy el 9 de Ag. de 2018
found the answer.
surf(X,Y,Z,C) additionally specifies the surface color.
[dfdx,dfdy] = gradient(Z);
surf(x,y,Z,sqrt(dfdx.^2 + dfdy.^2))
colorbar
does the trick...
Source and further Info can be found here

Más respuestas (1)

Yuvaraj Venkataswamy
Yuvaraj Venkataswamy el 8 de Ag. de 2018
if true
surf(X,Y,Z)
end
surf(X,Y,Z) creates a three-dimensional surface plot. The function plots the values in matrix Z as heights above a grid in the x-y plane defined by X and Y. The function also uses Z for the color data, so color is proportional to height.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by