How do I create a 2d surface plot for a function of x and y?

8 visualizaciones (últimos 30 días)
Danny La
Danny La el 3 de Mzo. de 2020
Editada: Kelly Kearney el 3 de Mzo. de 2020
This is what I tried
x=linspace(0,10)
y=linspace(0,10)
[xm,ym]=meshgrid(x,y)
fxy=sin(x).*cos(y)
surf(fxy)
but it gives me
Error using surf (line 71)
Z must be a matrix, not a scalar or vector.
Error in problem3 (line 5)
surf(fxy)

Respuestas (1)

Kelly Kearney
Kelly Kearney el 3 de Mzo. de 2020
Editada: Kelly Kearney el 3 de Mzo. de 2020
Change
fxy = sin(x).*cos(y)
to
fxy = sin(xm).*cos(ym)

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by