Difference in plots obtained from fsurf and surf command
23 次查看(过去 30 天)
显示 更早的评论
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')
采纳的回答
Srivardhan Gadila
2020-8-22
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!