如何在MatLab

时间:2018-05-20 18:56:04

标签: matlab plot

我试图用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);

有关如何做到的任何建议?

1 个答案:

答案 0 :(得分:0)

您有3个暗角的x箭头位置及其组成部分,但您需要3个组成部分作为其原点(xyz)。但是它们可以为零。

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

但是也许您想要更多时尚的东西?将此添加到底部:

我使用了viridis colormapthis答案。

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).');

enter image description here