Difference in plots obtained from fsurf and surf command
24 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Nikhil Yewale
el 18 de Ag. de 2020
Comentada: Gangala
el 1 de Dic. de 2022
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/347364/image.png)
in defined in region
and ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/347370/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/347367/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/347370/image.png)
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')
1 comentario
Respuesta aceptada
Srivardhan Gadila
el 22 de Ag. de 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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/350135/image.png)
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!