input=f(x) or f(x,y) how to plot/surf such unknown funktions?

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)

 Accepted 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');

2 Comments

thx so far.
but how to get z=input(f(x,y));? like f(x,y)=cosd(x)-sind(y)?
i dont want to change its colour
i want to know how to insert a function by hand
Z = ((((X .* exp(-X.^2 - Y.^2))));
in way that z= a new inserted funktion every time like x²+y or y²+x^4-2*xy or....

Sign in to comment.

More Answers (1)

If you like Andrei's suggestion
z = eval(['@(x,y)',input('f(x,y) = ','s')])
Then user enters:
cosd(x)-sind(y)
ezmesh(z)

1 Comment

ok now i see that this idea "hey let's write a program to show all funktions inserted!"is getting pretty hard for someone who just startet with it^^
thx by now
i'll try to get it rdy for use.

Sign in to comment.

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!