How to skip vectors and plot the n-vector with quiver ( 2D-vecor-vector field)

17 ビュー (過去 30 日間)
Emerson De Souza
Emerson De Souza 2011 年 10 月 19 日
回答済み: ali veli 2019 年 3 月 6 日
I want to know how to skip some rows by plotting a two-dimensional vector-field.
For example, let U and V be the coordinates and x and y the vector components as writen below:
U=[1 2 3 4 5 6 7 8 9 10];
V=[0 0 0 0 0 0 0 0 0 0];
x=[0 0 0 0 -1 1 0 2 1 2];
y=[1 2 -1 -2 0 0 0 0 1 2];
then I use quiver to plot the vector-field as follows:
Vector=[U' V' x' y'];
quiver(Vector(:,1),Vector(:,2),Vector(:,3),Vector(:,4),0,'LineWidth',2,'MaxHeadSize',.1); axis([0 12 -3 3])
Now it would be great if someone could tell me what I need to write to plot only every second, third or n-vector (row)
I thank you in advancoe for your help
Emerson

採用された回答

the cyclist
the cyclist 2011 年 10 月 19 日
Put these two lines in before the quiver() command:
plotEveryThisMany = 2;
Vector = Vector(1:plotEveryThisMany:end,:)
This will index into "Vector" at every other element. This can be generalized to choose whatever elements you want to plot.
  2 件のコメント
Emerson De Souza
Emerson De Souza 2011 年 10 月 19 日
Thank you,
it has been a great suggestion. It fixed my problem!!!
Do you also know how to skip data by plotting 2d-curves?
I frequent have to do with this issue and don't know how.
For example, let:
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y);
What should I write if I want to display only every n-ten data point?
Thank you in advance
Emerson
the cyclist
the cyclist 2011 年 10 月 20 日
You could do it like this:
xToPlot = x(1:10:end);
yToPlot = y(1:10:end);
plot(xToPlot,yToPlot)

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

その他の回答 (2 件)

Sachini Pathirana
Sachini Pathirana 2019 年 2 月 14 日
編集済み: Sachini Pathirana 2019 年 2 月 14 日
How can I use the same thing to select points in a 2D matrix? I have a mtrix of 695*1028 and i want to plot selected points using quiver.

ali veli
ali veli 2019 年 3 月 6 日
Hi. How do I get this vector graphic with quiver3grafik.png

カテゴリ

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