Problem with adjusting axis limits in surface plot

조회 수: 15 (최근 30일)
Pelajar UM
Pelajar UM 2022년 5월 9일
댓글: Pelajar UM 2022년 5월 9일
Here's the code. I want to show only X values between 0 and 1. Y values between 0.001 and 1000, and adjust the Z automatically.
YS = @(X,Y) (0.38*X^2-0.31*X-0.02)*log(Y)+2.7287*sin(1.1732*X+1.1613);
%the coefficients are not constant numbers, this is just an example.
fsurf(Z);
xlim ([0 1]);
ylim ([0.001 1000]);
When I first plot the surface, this is how it looks like:
After I double click on the plot, it adjusts the Z automatically to this:
How do you get the second/correct view without interacting with the plot?

채택된 답변

KSSV
KSSV 2022년 5월 9일
Use zlim as well.
zlim([-3 3])
  댓글 수: 3
KSSV
KSSV 2022년 5월 9일
I would rather prefer:
x = linspace(0,1) ;
y = linspace(0,1000) ;
[X,Y] = meshgrid(x,y) ;
Z = (0.38*X.^2-0.31*X-0.02).*log(Y)+2.7287*sin(1.1732*X+1.1613);
%the coefficients are not constant numbers, this is just an example.
surf(X,Y,Z);
Pelajar UM
Pelajar UM 2022년 5월 9일
Thanks a lot. This works perfectly.

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

추가 답변 (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