49 How to plot a surface? or how to plot $ f\left( x,y,z\right) $ function?

Problem: Plot the function

$\displaystyle z=x^{2}-2xy+3y+2
$

Using MATLAB we must define the range of $ x$ and $ y$, then use the function meshgrid() to create the $ xy$ grid, then evaluate $ z$ using the above equation, then use the function surf() to plot it. There are other functions to do 3d plots in MATLAB as well.

In Mathematica, define the function first and then use the Plot3D function.

Observations: In Matlab we have to manually define the range of x and y and the spacing between the points. Then use meshgrid to generate the xy points. In Mathematica, this is not needed, and is automatically handled. On the other hand, Matlab plots can be much easier analyzed. One can use the mouse to rotate the plot and zoom in and out and change many other aspects of the plot without having to reissue the plot command again and again as the case would be with Mathematica. So basically one needs to a little more work to generate the plots in Matlab than in Mathematica, but one the plot is generated, it is much easier and more powerful to analyze them on the screen using Matlab. This has always been something that Matlab was best at.

Image mma_e49
Mathematica solution.

Image matlab_e49
Matlab solution.

Nasser M. Abbasi
http://12000.org