![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1618848/image.png)
Replication of a skyrmion-like structure in MatLab
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello everyone
I have found this kind of "tutorial", skyrmion representation in MatLab, where a whirling structure in the shape of a skyrmion is plotted through 3D arrows. If I understood it correctly, the final figure it is based in 3D Arrow with many color/parameter options, and the script that it is used in the video it should be like this
clc;
clear all;
close all force;
addpath 'Path-to-the-3D-Arrow-with-many-color/parameter-options';
deltaV0=[0;0;-2];
for loop=0:6
nvv=3+5*loop;
rr=loop;
alpha1=linspace(0,2*pi,nvv);
[xx,yy]=pol2cart(alpha1,rr);
zz=0*xx;
postot=[xx',yy',zz'];
[iitot,~]=size(postot);
for ii=1:iitot
%% rotxx
theta=loop/6*pi;
rotxx=[1 0 0; ...
0 cos(theta) sin(theta); ...
0 -sin(theta) cos(theta)];
%% rotzz
phi=alpha1(ii);
rotzz=[cos(phi) -sin(phi) 0; ...
sin(phi) cos(phi) 0; ...
0 0 1];
%%
deltaV=rotzz*(rotxx*deltaV0);
deltaV=deltaV';
pos=postot(ii,:)-.5*deltaV;
arrow3D(pos,deltaV,deltaV(3))
end
end
axis equal tight off
caxis([-3 3]);
colormap jet
material dull
h1=light;
lightangle(h1,50,0);
lighting gouraud;
However, when I try to run it, I receive the following error
Error using matlab.graphics.chart.primitive.Surface
Error setting property 'FaceColor' of class
'Surface':
Invalid RGB triplet. Specify a three-element vector
of values between 0 and 1.
Error in surf (line 145)
hh = matlab.graphics.chart.primitive.Surface(allargs{:});
Error in arrow3D (line 94)
hStem = surf(stemX, stemY, stemZ, 'FaceColor', colorCode, 'EdgeColor', 'none');
Error in Skyrmion (line 29)
arrow3D(pos,deltaV,deltaV(3))
Does anyone have an idea where the error lies in the script I tried to copy from the aforementioned video?
0 Kommentare
Antworten (1)
Shubham
am 16 Feb. 2024
Hi Richard,
It seems that you are facing an error when trying to plot of 3D arrows using the provided File Exchange submission.
The “arrow3D” function calls the “surf” function for plotting a surface plot as shown in the error message provided. Also, the “colorCode” function argument of the “arrow3D” function has ‘interp’ as the default argument.
I have tried running the provided script using the following code snippet :
arrow3D(pos,deltaV)
The output produced is as follows :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1618848/image.png)
The function “arrow3D” requires a three-element vector (RGB triplet) of values between 0 and 1 as described in the error message for the positional argument “colorCode”. The “deltaV(3)” being passed in the function contains only one element.
Since the “surf” function is being used under the hood for plotting the arrows, you can refer to its documentation for more information:
I hope this helps!
0 Kommentare
Siehe auch
Kategorien
Mehr zu Orange finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!