У вас есть x
расположение стрелок и их компонентов в 3 тусклых оттенках, но вам нужно 3 компонента для их происхождения (x
, y
, z
).Хотя они могут быть равны нулю.
q=quiver3(x,zeros(size(x)),zeros(size(x)),Sxy*ones(size(x)),Syy,Szy,0); % last zero sets autoscale of arrows
Но, может быть, вы хотите что-то более стильное?Добавьте это внизу:
Я использовал viridis colormap и этот ответ.
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](https://i.stack.imgur.com/TLao6.png)