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

65 vues (au cours des 30 derniers jours)
Alec le 22 Mar 2023
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;
axis([-3 3 -3 3 -3 3])
rotate3d on
  1 commentaire
Alec le 22 Mar 2023
I tried x= -3:3 and y= -6:6 but That isnt correct (I think).

Connectez-vous pour commenter.

Réponse acceptée

John D'Errico
John D'Errico le 22 Mar 2023
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;

Plus de réponses (0)


En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange





Community Treasure Hunt

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

Start Hunting!

Translated by