フィルターのクリア

Is it possible to plot vectors in different colors using a single quiver statement?

4 ビュー (過去 30 日間)
Tintumon
Tintumon 2019 年 7 月 2 日
コメント済み: Tintumon 2019 年 7 月 2 日
Suppose I have the following code:
coltab = ([128,0,0; 0,255,0; 0,0,255; 255,255,0; 255,116,140])/255;
% I have the above colors predefined
x = [1:5];
y = [10:15];
u = [1 2 3 -4 -5];
v = [1 -1 -2 -3 2 ];
color_index = [1; 2; 2; 3; 4] %can be any value since it is computed seperately
I need to plot these vectors and its color must be based on the variable "color_index". One way to day is:
hold on;
for i=1:length(x)
quiver(x(i),y(i),u(i),v(i),'color', coltab(color_index(i,1),:));
end
hold off;
Here, based on the length of the data the "quiver" function is repeteadly called which is a slow process.
Is there any way to vectorize the for loop section and replace it with a single quiver statement ?
  2 件のコメント
dpb
dpb 2019 年 7 月 2 日
The quiver object is single handle for the entire object; there is no array to hold the 'Marker[Face|Edge]Color' properties separately by element so doesn't help even if were way to write without the loop.
You might search FEX to see if are any enhanced versions that do have the extra granularity already implemented.
Tintumon
Tintumon 2019 年 7 月 2 日
Thank you! So the straightforward answer to my question would be a NO!!

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

回答 (0 件)

カテゴリ

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by