필터 지우기
필터 지우기

Difference in plots obtained from fsurf and surf command

조회 수: 24 (최근 30일)
Nikhil Yewale
Nikhil Yewale 2020년 8월 18일
댓글: Gangala 2022년 12월 1일
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
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
  댓글 수: 1
Nikhil Yewale
Nikhil Yewale 2020년 8월 23일
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 ?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by