フィルターのクリア

How to set colors in quiver (2D)?

143 ビュー (過去 30 日間)
noa
noa 2012 年 9 月 20 日
コメント済み: Jean 2015 年 8 月 25 日
Hi, im using the quiver function to plot arrows on a profile
so i want that the arrows which are turning inwards to be colored in a different color (blue). Also, i have a vector telling me which of them is turning inwards.
how can i do that?
thanks, Noa
  2 件のコメント
José-Luis
José-Luis 2012 年 9 月 20 日
I see you decided to go with the quiver suggestion. If an answer has helped you, please accept it.
noa
noa 2012 年 9 月 20 日
:)

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

採用された回答

Wayne King
Wayne King 2012 年 9 月 20 日
編集済み: Wayne King 2012 年 9 月 20 日
I would separate the elements which are turning inward vs outward since you have a vector of indices and use two different calls to quiver() with the plot held on.
Then you can use
quiver(x,y,px,py,'color',[0 0 1])
In other words, use the 'color' linespec to color them blue. For example:
[x,y] = meshgrid(-2:.2:2,-1:.15:1);
z = x .* exp(-x.^2 - y.^2); [px,py] = gradient(z,.2,.15);
contour(x,y,z), hold on
indices = 11:21;
quiver(x(:,indices),y(:,indices),px(:,indices),py(:,indices),'color',[0 0 1]);
quiver(x(:,1:10),y(:,1:10),px(:,1:10),py(:,1:10),'color',[1 0 0]);
  1 件のコメント
Jean
Jean 2015 年 8 月 25 日
Thanks a lot. It works!

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

その他の回答 (0 件)

カテゴリ

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