surface plot with white patches on using fsurf, but complete surface using ezsurf
10 views (last 30 days)
Show older comments
Hi!
I am trying to plot potential energy surfaces using the fsurf function. What I do/need is fairly simple:
syms x y E %the energy, E, is a function of the coordinates, x and y
Av2=[(8300*(0.2*x^4 + x^2 + 0.2*y^4 + y^2))/(0.2 + 1) - E,1070,0;1070, 7700 - E + 3800*((x - 1/2)^2 + (y - 3^(1/2)/2)^2),1070;0,1070,(8300*((x - 1/2)^2 + 0.2*y^4 + y^2 + 0.2*(x - 1)^4))/(0.2 + 1) - E];
detAv2=det(Av2);
solAv2=solve(detAv2,E,'MaxDegree',3); %I want to get explicit solutions without the index placeholder z; I get three solutions here, and I need (to plot) the third one
fsurf(solAv2(3,1),[-0.5 1.5 -0.5 1.5])
On using fsurf, I get a plot with white patches, as seen below:
If the plot was filled out, it would be correct. As suggested in another question about fsurf and ezsurf a couple of years ago, I did try to turn off the 'AdaptiveMeshDensity' feature, but it didn't work. On the other hand, ezsurf gives the correct result:
I tried to do other things, such as forcing real solutions, trying to get simpler solutions etc. by using 'IgnoreAnalyticConstraints', 'Real', etc. But plotting them didn't help either, and gives the same problems. I have no insight into how the two functions are actually different, and why ezsurf is able to compute the correct surface, but fsurf is not. Please help.
Edit: I am using R2020a
0 Comments
Accepted Answer
Star Strider
on 21 Aug 2020
The function produces complex values, and MATLAB plots plot only real values.
One option is to use the abs function:
fsurf(abs(solAv2(3,1)),[-0.5 1.5 -0.5 1.5])
producing this plot:
.
2 Comments
Star Strider
on 21 Aug 2020
As always, my pleasure!
My guess is that ezsurf detects the complex values and automatically uses the abs function. Using only the real part of a complex result may not produce the result you want.
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!