Need help using mesh and surf

조회 수: 1 (최근 30일)
Shawn
Shawn 2014년 2월 22일
댓글: Shawn 2014년 2월 22일
Im trying to generate a surface plot using the following variables,
-10<x<10
-10<y<10
t=sqrt(x^2 + y^2)
z=sin(t)/t
when i try to use the surf (or mesh) command it gives me an error saying that Z must be a matrix and not a scaler or vector. I've tried surf(x,y,z) and many other variations, but to no avail. Please help.

채택된 답변

Mischa Kim
Mischa Kim 2014년 2월 22일
편집: Mischa Kim 2014년 2월 22일
Shawn, use
[X,Y] = meshgrid(-10:0.5:10, -10:0.5:10);
t = sqrt(X.^2 + Y.^2);
Z = sin(t)./t;
surf(X,Y,Z)
  댓글 수: 1
Shawn
Shawn 2014년 2월 22일
Thank you so much for the quick response!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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