Circular vortex with spin vectors
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I need help to create a circular vortex with different polarizations like converging, diverging and clockwise etc.,
I attached an image for reference.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1440843/image.jpeg)
2 Commenti
Risposte (2)
Dyuman Joshi
il 24 Lug 2023
% Parameters
numPoints = 50; % Number of points in the vortex
spinMagnitude = 0.5; % Magnitude of the spin vectors
r1 = 1; % Radius of the outer vortex
r2 = 0.5; %Radius of the inner vortex
% Generate theta values
theta = linspace(0, 2*pi, numPoints);
% Generate x and y coordinates
x = cos(theta);
y = sin(theta);
% Generate spin vectors
spinVectors = spinMagnitude * ones(size(x));
%%Radially outward arrows
figure;
quiver(r1*x, r1*y, spinVectors.*x, spinVectors.*y, 'b');
hold on
quiver(r2*x, r2*y, spinVectors.*x, spinVectors.*y, 'b');
axis equal;
xlabel('X');
ylabel('Y');
%%Radially outward arrows leaning in a counter clockwise direction
figure
quiver(r1*(x+y), r1*(y-x), spinVectors.*x, spinVectors.*y, 'b');
hold on
quiver(r2*(x+y), r2*(y-x), spinVectors.*x, spinVectors.*y, 'b');
axis equal;
xlabel('X');
ylabel('Y');
4 Commenti
Dyuman Joshi
il 31 Lug 2023
Do you only have these images to work with? or do you have any data or any other piece of information?
Bruno Luong
il 31 Lug 2023
Modificato: Bruno Luong
il 31 Lug 2023
[x,y] = ndgrid(linspace(-1,1,10));
x = x(:)';
y = y(:)';
xy = [x; y];
r = vecnorm(xy, 2, 1);
r(r > 1) = NaN;
xyn = xy ./ r;
for k=1:12
Psi = 2*pi*rand();
R = [cos(Psi), -sin(Psi);
sin(Psi), cos(Psi)];
V = R * xyn;
vx = V(1,:);
vy = V(2,:);
subplot(3,4,k);
quiver(x, y, vx, vy, 'linewidth', 2);
set(gca, 'visible', 'off')
end
2 Commenti
Bruno Luong
il 31 Lug 2023
Modificato: Bruno Luong
il 31 Lug 2023
Feel free to adapt my code to your need.
I gave you a recipe of the cake, if you want strawberry flavor, you need to adapt my recipe and make your own cake.
Vedere anche
Categorie
Scopri di più su Assembly in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!