MATLAB: Input=f(x) or f(x,y) how to plot/surf such unknown funktions

inputplotsurf

i am planning to write a program which is able to plot/surf an inserted function input=f(x,y)
i want to use it just to make those functions visable in 2d/3d for my maths class so my questions are:
how to get an function into matlab?
and how to plot/surf that unknown function?
———————-
ich möchte ein programm schreiben dass es mir ermöglicht mathematische funktionen (f(x,y) einzulesen und diese optisch auf dem bildschirm ausgibt um sie besser im unterricht besprechen zu können (erweiterungen des programmes werden dann ggf nullstellen berechnung etc)

Best Answer

[X,Y] = meshgrid(-2:.2:2, -4:.4:4);
Z = X .* exp(-X.^2 - Y.^2);
surf(X,Y,Z)
Then you might want to shade
shading('interp');
or
shading('flat');