MATLAB: How to plot “f(x,y) = x^2 * y^3” and its partial derivative function in matlab

3d plotsMATLABmatlab function

I am a beginner, so I am unfamiliar with matlab. I am trying to plot a function: f(x, y) =x^2 * y^3" and its partial derivative, but it looks like something wrong. I am also trying another way but it looks absolutely different with a result I got from Google. Please help me. Thank you so much.

Best Answer

x = linspace(-1,1) ;
y = linspace(-1,1) ;
[X,Y] = meshgrid(x,y) ;
f = X.^2.*Y.^3 ;
dfdx = 2*X.*Y.^3 ;
dfdy = 3*X.^2.*Y.^2 ;
figure ; surf(X,Y,f) ; title('f') ;
figure ; surf(X,Y,dfdx) ; title('df/dx') ;
figure ; surf(X,Y,dfdy) ; title('df/dy') ;