Wrongly oriented plots while drawing spherical harmonics

Hello everyone. I am trying to create a simple app, using appdesigner, that will plot spherical harmonics.
Everything works fine, but in some configurations of quantum numbers (l=3, m= -1 ; l=4, m = -2; l = 5, m= -3) and so on the plot seems to be "differently oriented" which looks kind of odd. I tried to set SortMethod explicitly to 'depth' but it didn't change the result. What is funny, when I set it explicitly to 'childorder' it changed the appearance of all the plots to the unwanted one (all of them were wrongly oriented). I attach my code and pictures of how the plots look like:
syms theta phi l m x;
l = ll;
subs(l);
m = mm;
subs(m);
eq = (x^2 - 1)^(l);
Df = diff(eq,x,l+m);
Plm = (-1)^(m)/(2^(l)*factorial(l))*(1-x^2)^(m/2)*Df;
x = cos(theta);
a = (2*l+1)*factorial(l-m);
b = 4*pi*factorial(l+m);
C = sqrt(a/b);
Ylm = C*subs(Plm)*exp(1i*m*phi);
r = @(phi,theta) abs(Ylm);
x = r*cos(phi)*sin(theta);
y = r*sin(phi)*sin(theta);
z = r*cos(theta);
fsurf(app.UIAxes,x,y,z,[0 2*pi 0 pi]);
app.UIAxes.SortMethod = 'depth';
How it looks like for l = 3, m = 1 (that's the desired appearance)
How it looks like for l = 3, m = -1:
Does anyone know how to solve it? Thanks in advance
Karol

2 comentarios

Both your pictures are labled with "l = 3, m = -1". Is that a mistake?
Also, what is the output from this command when you run in on both pictures?
rendererinfo(app.UIAxes)
Hello Benjamin, thank you for your response.
In regard to the labelling - you're right, it's a mistake. I've changed it already. The first picture was drawn for quantum numbers l = 3, m = +1.
The output for BOTH pictures is as follows:
struct with fields:
GraphicsRenderer: 'WebGL'
Vendor: 'Google Inc.'
Version: 'WebGL 2.0 (OpenGL ES 3.0 Chromium)'
RendererDevice: 'ANGLE (Intel(R) HD Graphics 530 Direct3D11 vs_5_0 ps_5_0)'
Details: [1×1 struct]
I also encountered another problem. When I try to change the camera line of sight for those incorrectly drawn pictures, using:
view(app.UIAxes, 26, 25);
I receive some very strange error messages (they are not always the same - their order and number vary). I attach an example:
Warning: An error occurred while drawing the scene: Error in web cull traversal: Error: Frustum
Planes are not correct
Warning: An error occurred while drawing the scene: Error in web draw traversal: Error: Matrix
should be set with finite elements only
Warning: An error occurred while drawing the scene: Error in web cull traversal: Error: Frustum
Planes are not correct
Warning: An error occurred while drawing the scene: Error in web cull traversal: Error: Frustum
Planes are not correct
Warning: An error occurred while drawing the scene: Error in web cull traversal: Error: Frustum
Planes are not correct
When I try to use the view function - the plot is not drawn at all. When I do not use them - it is drawn, but it looks like the example in the second picture.
I tried to execute a script with exactly the same code and it worked fine. However, the rendereinfo function's output is different:
struct with fields:
GraphicsRenderer: 'OpenGL Hardware'
Vendor: 'NVIDIA Corporation'
Version: '4.5.0 NVIDIA 376.54'
RendererDevice: 'GeForce GTX 960M/PCIe/SSE2'
Details: [1×1 struct]
So it's probably the case of renderer. The problem is - I don't know how to change it in the appdesigner. I tried
opengl hardware
and
opengl('save','hardware')
But neither of those worked.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Language Fundamentals en Centro de ayuda y File Exchange.

Productos

Versión

R2020b

Preguntada:

el 10 de En. de 2021

Editada:

el 13 de En. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by