How to specify a domain of x and y values for a graph?

조회 수: 38 (최근 30일)
Alec
Alec 2023년 3월 22일
답변: John D'Errico 2023년 3월 22일
I cant seem to get this to work
I am plotting a 3d graph, and I am told to graph it over the domain of
This is my code so far:
syms x y
f = y^2*(3/4)+y^3*(1/24)-y^4*(1/32)-x^2;
fsurf(f)
axis([-3 3 -3 3 -3 3])
rotate3d on
  댓글 수: 1
Alec
Alec 2023년 3월 22일
I tried x= -3:3 and y= -6:6 but That isnt correct (I think).

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

채택된 답변

John D'Errico
John D'Errico 2023년 3월 22일
Did you read the help for fsurf? What does the second argument do?
help fsurf
FSURF Plot 3-D surface FSURF(FUN) creates a surface plot of the function FUN(X,Y). FUN is plotted over the axes size, with a default interval of -5 < X < 5, -5 < Y < 5. FSURF(FUN,INTERVAL) plots FUN over the specified INTERVAL instead of the default interval. INTERVAL can be the vector [XMIN,XMAX,YMIN,YMAX] or the vector [A,B] (to plot over A < X < B, A < Y < B). FSURF(FUNX,FUNY,FUNZ) plots the parametric surface FUNX(U,V), FUNY(U,V), and FUNZ(U,V) over the interval -5 < U < 5 and -5 < V < 5. FSURF(FUNX,FUNY,FUNZ,[UMIN,UMAX,VMIN,VMAX]) or FSURF(FUNX,FUNY,FUNZ,[A,B]) uses the specified interval. FSURF(AX,...) plots into the axes AX instead of the current axes. H = FSURF(...) returns a handle to the surface object in H. Examples: fsurf(@(x,y) x.*exp(-x.^2-y.^2)) fsurf(@(x,y) besselj(1,hypot(x,y))) fsurf(@(x,y) besselj(1,hypot(x,y)),[-20,20]) % this can take a moment fsurf(@(x,y) sqrt(1-x.^2-y.^2),[-1.1,1.1]) fsurf(@(x,y) x./y+y./x) fsurf(@peaks) f = @(u) 1./(1+u.^2); fsurf(@(u,v) u, @(u,v) f(u).*sin(v), @(u,v) f(u).*cos(v),[-2 2 -pi pi]) A = 2/3; B = sqrt(2); xfcn = @(u,v) A*(cos(u).*cos(2*v) + B*sin(u).*cos(v)).*cos(u) ./ (B - sin(2*u).*sin(3*v)); yfcn = @(u,v) A*(cos(u).*sin(2*v) - B*sin(u).*sin(v)).*cos(u) ./ (B - sin(2*u).*sin(3*v)); zfcn = @(u,v) B*cos(u).^2 ./ (B - sin(2*u).*sin(3*v)); h = fsurf(xfcn,yfcn,zfcn,[0 pi 0 pi]); If your function has additional parameters, for example k in myfun: %------------------------------% function z = myfun(x,y,k1,k2,k3) z = x.*(y.^k1)./(x.^k2 + y.^k3); %------------------------------% then you may use an anonymous function to specify that parameter: fsurf(@(x,y)myfun(x,y,2,2,4)) See also FPLOT, FPLOT3, FMESH, FIMPLICIT3, SURF, VECTORIZE, FUNCTION_HANDLE. Documentation for fsurf doc fsurf Other uses of fsurf symbolic/fsurf
syms x y
f = y^2*(3/4)+y^3*(1/24)-y^4*(1/32)-x^2;
fsurf(f,[-3,3,-6,6])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Networks에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by