簡體   English   中英

如何在MatLab中可視化以3D旋轉的矢量

[英]How to visualize a vector rotating in 3D in MatLab

我正在嘗試使用MatLab可視化我的自旋密度在空間中的旋轉方式。 據我所能調查的,如果我沒有記錯的話,就有羽毛和quiver3環境用於這種目的。 我正在尋找的是,您可以使用箭頭作為圖形指示器來跟蹤演變。

向量的三個分量依賴於一個變量,我們稱它為x,甚至其分量之一為零:

x=[0:0.01:10]
Sxy=0;
Syy=(cos(sqrt(2*sqrt(2)+1)*x)+(sqrt(7)/(11+8*sqrt(2)))*sin(sqrt(2*sqrt(2)+1)*x)).*exp(-sqrt(2*sqrt(2)-1)*x);
Szy=-(2/(77+56*sqrt(2)))*(-7*sqrt(1+2*sqrt(2))+11*sqrt(-7+14*sqrt(2))+8*sqrt(-14+28*sqrt(2)))*exp(-sqrt(2*sqrt(2)-1)*x).*sin(sqrt(2*sqrt(2)+1)*x);

關於如何完成的任何建議?

您有3個暗角的箭頭及其分量的x位置,但是它們的原點( xyz )需要3個分量。 但是它們可以為零。

q=quiver3(x,zeros(size(x)),zeros(size(x)),Sxy*ones(size(x)),Syy,Szy,0); % last zero sets autoscale of arrows

但是也許您想要更多時尚的東西? 在底部添加:

我使用了viridis顏色圖答案。

set(q,'MaxHeadSize',0.03,'AutoScaleFactor',0);
set(q,'LineWidth',2);
%// Compute the magnitude of the vectors
mags = sqrt(sum(cat(2, q.UData(:), q.VData(:), ...
            reshape(q.WData, numel(q.UData), [])).^2, 2));

%// Get the current colormap
currentColormap = colormap(viridis);

%// Now determine the color to make each arrow using a colormap
[~, ~, ind] = histcounts(mags, size(currentColormap, 1));

%// Now map this to a colormap to get RGB
cmap = uint8(ind2rgb(ind(:), currentColormap) * 255);
cmap(:,:,4) = 255;
cmap = permute(repmat(cmap, [1 3 1]), [2 1 3]);

%// We repeat each color 3 times (using 1:3 below) because each arrow has 3 vertices
set(q.Head, ...
    'ColorBinding', 'interpolated', ...
    'ColorData', reshape(cmap(1:3,:,:), [], 4).');   %'

%// We repeat each color 2 times (using 1:2 below) because each tail has 2 vertices
set(q.Tail, ...
    'ColorBinding', 'interpolated', ...
    'ColorData', reshape(cmap(1:2,:,:), [], 4).');

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM