How can I plot a skyrmion to sphere similar to the following picture
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
玥
le 11 Avr 2024
Commenté : Manikanta Aditya
le 11 Avr 2024

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 commentaires
Manikanta Aditya
le 11 Avr 2024
Modifié(e) : Manikanta Aditya
le 11 Avr 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.
Réponse acceptée
Manikanta Aditya
le 11 Avr 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;
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

