How can I plot a skyrmion to sphere similar to the following picture

9 visualizaciones (últimos 30 días)
I'm a beginner in MATLAB, and I'm curious about how to plot 3D arrows mapped onto a sphere, similar to the image shown. I believe the problem can be divided into two steps: first, plotting arrows resembling a skyrmion, and then projecting them onto a sphere. Can you provide guidance on how to achieve this?
  2 comentarios
Manikanta Aditya
Manikanta Aditya el 11 de Abr. de 2024
Editada: Manikanta Aditya el 11 de Abr. de 2024
Hi, Check this workaround which shows what you require:
% Define the number of arrows
n = 100;
% Generate spherical coordinates (theta and phi)
theta = linspace(0, pi, n);
phi = linspace(0, 2*pi, n);
[Theta, Phi] = meshgrid(theta, phi);
% Calculate 3D coordinates (x, y, z) from spherical coordinates
x = sin(Theta) .* cos(Phi);
y = sin(Theta) .* sin(Phi);
z = cos(Theta);
% Define the arrow vectors (u, v, w) based on the desired skyrmion-like pattern
u = -sin(Phi);
v = cos(Phi);
w = zeros(size(Theta));
% Scale the arrow vectors
scale = 0.3;
u = u * scale;
v = v * scale;
w = w * scale;
% Plot the sphere
[X, Y, Z] = sphere;
surf(X, Y, Z, 'FaceColor', 'texture', 'EdgeColor', 'none')
colormap bone
axis equal
hold on
% Plot the arrows on the sphere
quiver3(x, y, z, u, v, w, 'Color', 'r', 'LineWidth', 1)
hold off
If you found this helpful, let me know I will post it as answer, you can accept it.
玥
el 11 de Abr. de 2024
Thank you very much for your response, it has been very helpful.
Building upon this, I'd like to inquire about how to make the color of the arrows vary gradually along the surface of the sphere. Could you please provide guidance on achieving this?

Iniciar sesión para comentar.

Respuesta aceptada

Manikanta Aditya
Manikanta Aditya el 11 de Abr. de 2024
Hi,
To add to the earlier response, to know about making the color of the arrows vary gradually along the surface of the sphere. Check this functionationality of the code as per my understanding it should look this way:
% Define the number of arrows
n = 100;
% Generate spherical coordinates (theta and phi)
theta = linspace(0, pi, n);
phi = linspace(0, 2*pi, n);
[Theta, Phi] = meshgrid(theta, phi);
% Calculate 3D coordinates (x, y, z) from spherical coordinates
x = sin(Theta) .* cos(Phi);
y = sin(Theta) .* sin(Phi);
z = cos(Theta);
% Define the arrow vectors (u, v, w) based on the desired skyrmion-like pattern
u = -sin(Phi);
v = cos(Phi);
w = zeros(size(Theta));
% Scale the arrow vectors
scale = 0.3;
u = u * scale;
v = v * scale;
w = w * scale;
% Plot the sphere
[X, Y, Z] = sphere;
surf(X, Y, Z, 'FaceColor', 'texture', 'EdgeColor', 'none')
colormap bone
axis equal
hold on
% Plotting arrows with colors varying along Phi
colors = Phi; % or use another parameter that varies across your sphere
quiver3(x, y, z, u, v, w, 'Color', 'r', 'LineWidth', 1,'AutoScale','off');
hold off;

Más respuestas (0)

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!

Translated by