
f(x,y) = xy/(x²+y²) ,(x,y)≠(0,0), f(x,y)= 0 , x=y=0.How to draw a graphics by using Matlab.
4 次查看(过去 30 天)
显示 更早的评论
I mean i don't know how to express f(x,y)= 0 , x=y=0 .
0 个评论
采纳的回答
Dimitris Kalogiros
2018-8-20
Provided that you have symbolic maths toolbox you can use the following code :
clear; clc;
syms x y
% define function
f(x,y)=piecewise(x==0 & y==0, 0 , x*y/(x^2+y^2) )
%plot function
fsurf(f(x,y));
xlabel('x'); ylabel('y'); zlabel('f(x,y)')
This is what you should expect:

1 个评论
Walter Roberson
2018-8-20
f(x,y)=piecewise(x==0 & y==0, 0 , x*y/(x^2+y^2) )
should be
f(x,y)=piecewise(x==0 & y==0, 0 , (x^2+y^2)/sin(x^2+y^2) )
to match the initial question.
Unfortunately the fsurf() for this is slow. It also goes to +/- infinity in a number of places because sin() goes to 0 in a number of places. Basically the fsurf() is unusable unless you restrict the bounds a fair bit.
更多回答(1 个)
Walter Roberson
2018-8-20
f = @(x,y) (x.^2 + y.^2) .* sin(1 ./ max( x.^2 + y.^2, realmin ))
This code is incorrect for the case that x^2 + y^2 is less than realmin.
In such a case, the formula requires taking sin(1/small_value) where 1/small_value is greater than realmax, which therefore becomes sin(inf) which is NaN -- that is, the formula requires that NaN be generated for that situation. But the code does not do that for x^2 + y^2 between eps(realmin) and realmin: instead it will take sin(1/realmin) which has a definite value of about -0.955607093583484
If you require that NaN be generated for that case, then some more work would have to be done -- and you would get a different situation if you were permitted to do the calculation using the Symbolic Toolbox.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numbers and Precision 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!