how to limit arrow length in 3D quiver plot?

13 ビュー (過去 30 日間)
A
A 2012 年 4 月 5 日
I have a vector field with a large dynamic range; I would like to set a high threshold on vector magnitudes being displayed.
logarithmic scale would also help.

採用された回答

A
A 2012 年 5 月 14 日
here is what works:
Ln = sqrt(U.^2 + V.^2 +W.^2);
Maxlen=100;
U(Ln>Maxlen)=U(Ln>Maxlen)./Ln(Ln>Maxlen).*Maxlen;
V(Ln>Maxlen)=V(Ln>Maxlen)./Ln(Ln>Maxlen).*Maxlen;
W(Ln>Maxlen)=W(Ln>Maxlen)./Ln(Ln>Maxlen).*Maxlen;
quiver3(X,Y,Z,U,V,W)

その他の回答 (2 件)

Matt Kindig
Matt Kindig 2012 年 4 月 5 日
For your situation, I would specify the length of the arrows directly, rather than letting Matlab perform the Auto-scaling of the vectors. This would allow you to specify upper bounds on the lengths, log scaling, or whatever else you prefer. Something like this:
% X,Y,Z are the origins of your vectors
% U,V,W are the directions of your vectors
Ln = sqrt(U.^2 + V.^2 +W.^2);
U = U./Ln; V = V./Ln; W = W./Ln; %normalize vectors
Maxlen = 100; %set this based on your preference
U = U*Maxlen; %this will set 'Maxlen' as the max length
V = V*Maxlen;
W = W*Maxlen;
%or for log scaling,
U = Maxlen*log(U); %or similar
V = Maxlen*log(V);
U =
hq = quiver3( X, Y, Z,
  2 件のコメント
A
A 2012 年 4 月 5 日
wouldn't this set all vectors to the same length?
Matt Kindig
Matt Kindig 2012 年 4 月 5 日
Ah, yes it would. My apologies. You should normalize by the maximum of Ln, rather than Ln itself.

サインインしてコメントする。


Sean de Wolski
Sean de Wolski 2012 年 4 月 5 日
Couldn't you just takle the log or log10 f the u/v/w components?
2-d example:
[xx yy] = meshgrid(1:5);
u = (rand(5)+1).^(rand(5)*10);
v = (rand(5)+1).^(rand(5)*10);
quiver(xx(:),yy(:),log10(u(:)),log10(v(:)))
More per comments Let's not give up on this yet!
[xx yy] = meshgrid(1:5);
u = (rand(5)+1).^(rand(5)*10)*sign(randn(5));
v = (rand(5)+1).^(rand(5)*10)*sign(randn(5));
quiver(xx(:),yy(:),sign(u(:)).*log10(abs(u(:))),sign(u(:)).*log10(abs(v(:))))
  2 件のコメント
A
A 2012 年 4 月 5 日
components could be negative; log would not work
Sean de Wolski
Sean de Wolski 2012 年 4 月 5 日
please see update.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by