Difference in plots obtained from fsurf and surf command

42 views (last 30 days)
Hello,
I would be glad if anyone points out why fsurf and surf command show different plots(attached with this question) for the following function that I wish to visualize:
in defined in region and
Following is the my MATLAB script for plotting using fsurf and surf command. Plot obtained using surf matches correctly with the one obtained from wolfram mathematica, whereas one obtained from fsurf is unable to plot values near the corner of domain i.e. near [10,10]
Attachments- using_mathematica.png
using_fsurf.png
using_surf.png
close all;
C = 1/9;
%% need to visualize following function in [0 10] square domain
K = @(X,Y) sqrt(Y).*(X.^(3/2)).*exp(-C.*(X.^3 + Y.^3)).*...
besseli(1/3,(2/9).*(X.^(3/2)).*(Y.^(3/2)));
%% plot using fsurf
figure(1)
fsurf(K,[0 10 0 10])
xlabel('X')
ylabel('Y')
zlabel('K')
title('Plot using fsurf')
%% plot using surf
[X,Y] = meshgrid(0:0.1:10);
figure(2)
surf(X,Y,K(X,Y))
xlabel('X')
ylabel('Y')
title('Plot using surf')
zlabel('K')

Accepted Answer

Srivardhan Gadila
Srivardhan Gadila on 22 Aug 2020
As per my knowledge, I think the difference is due to the overflow of besseli function and the implementation of the fsurf function.
You can experiment with the below code:
close all;
C = 1/9;
%% need to visualize following function in [0 10] square domain
% K = @(X,Y) sqrt(Y).*(X.^(3/2)).*exp(-C.*(X.^3 + Y.^3)).*...
% besseli(1/3,(2/9).*(X.^(3/2)).*(Y.^(3/2)));
K1 = @(X,Y) sqrt(Y).*(X.^(3/2)).*exp(-C.*(X.^3 + Y.^3));
K2 = @(X,Y) besseli(1/3,(2/9).*(X.^(3/2)).*(Y.^(3/2)));
K = @(X,Y) K1(X,Y).*K2(X,Y);
%% plot using fsurf
figure(1)
subplot(2,3,1); fs = fsurf(K1,[0 10],'MeshDensity',100);
subplot(2,3,2); fs = fsurf(K2,[0 10],'MeshDensity',100);
subplot(2,3,3); fs = fsurf(K,[0 10],'MeshDensity',100);
xlabel('X')
ylabel('Y')
zlabel('K')
title('Plot using fsurf')
%% plot using surf
[X,Y] = meshgrid(0:0.1:10);
subplot(2,3,4); surf(X,Y,K1(X,Y));
subplot(2,3,5); surf(X,Y,K2(X,Y));
subplot(2,3,6); surf(X,Y,K(X,Y));
xlabel('X')
ylabel('Y')
title('Plot using surf')
zlabel('K')
I have split the original function into two functions K1 & K2, where K2 is the besseli function, In the below plots you can observe the overflow
  1 Comment
Nikhil Yewale
Nikhil Yewale on 23 Aug 2020
That's correct. Thank you for the answer .The besseli function does shoot up at larger values of X and Y.
But shouldn't fsurf and surf give same plots regardless ? Does this warrant for fixing any issues in fsurf function ?

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!