필터 지우기
필터 지우기

Help plotting with simple linespace and surf?

조회 수: 3 (최근 30일)
Taylor Gates
Taylor Gates 2018년 7월 12일
답변: Rik 2018년 7월 13일
I'm trying to generate xy grid, and plot the 3D surface, z=sin(3*x).^2.*cos(4*y)^3, where x and y ranges from -pi to pi.
I'm getting an error with my SURF and can't figure out why. Here's my code so far.
x=linspace(0,2*pi); y=linspace(0, pi); [X,Y]= meshgrid(x,y); Z=sin(3*x).^2.*cos(4*y).^3 surf(X,Y,Z)

채택된 답변

Rik
Rik 2018년 7월 13일
You were very close: you only forgot to change x to X and y to Y after you added meshgrid.
x=linspace(0,2*pi);
y=linspace(0, pi);
[X,Y]= meshgrid(x,y);
Z=sin(3*X).^2.*cos(4*Y).^3;
surf(X,Y,Z)
(next time, select your code and click the {}Code button to correctly format your code)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Lighting, Transparency, and Shading에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by