Creating a vector field

55 ビュー (過去 30 日間)
Johannes
Johannes 2012 年 11 月 27 日
コメント済み: Nitin Phadkule 2021 年 10 月 9 日
Hello everybody,
I am trying to create a vector field. The vector at each point is combined out of two others.
I tried
[x,y] = meshgrid(-2:.2:2,-2:.2:2) ; to create the points I want to take a look at
VectorX = [x./(2*pi*(x.^2+y.^2)),0]; is the Vector in the "x" direction
VectorY = [0,y./(2*pi*(x.^2+y.^2))]; is the Vector in the "y" direction
Vectortoplot = [(x./(2*pi*(x.^2+y.^2))),(y./(2*pi*(x.^2+y.^2)))];
quiver(x,y,Vectortoplot)
But all I get is an empty coordinat system form 0 to 1 in 0.1 steps in each direction. I am a little confused.
If you could help me, I would be very thankful.
  2 件のコメント
Jan
Jan 2012 年 11 月 28 日
Please learn how to format code in the forum. Inserting white lines does not look fancy.
Johannes
Johannes 2012 年 11 月 29 日
I know, i am new in matlab, and this was the fastest way for me.
I will try to do that in the future, however i would be thankful for some help

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

回答 (1 件)

Babak
Babak 2012 年 11 月 28 日
編集済み: Babak 2012 年 11 月 28 日
I don't know why you put a zero at the end of VectorX and a zero at the beginning of VectorY which makes those lines incorrect.
Your usage of quiver doesn't seem to be proper either. quiver needs 4 inputs. See
doc quiver
on that.
Here's what I ran:
[x,y] = meshgrid(-2:.2:2,-2:.2:2) ; %to create the points I want to take a look at
VectorX = [x./(2*pi*(x.^2+y.^2))]; %is the Vector in the "x" direction
VectorY = [y./(2*pi*(x.^2+y.^2))]; %is the Vector in the "y" direction
Vectortoplot = [(x./(2*pi*(x.^2+y.^2))),(y./(2*pi*(x.^2+y.^2)))];
% size(x)
% size(y)
% size(VectorX)
% size(VectorY)
quiver(x,y,VectorX,VectorY)
  3 件のコメント
Rupchand Sutradhar
Rupchand Sutradhar 2021 年 7 月 5 日
編集済み: Rupchand Sutradhar 2021 年 7 月 5 日
how can I set the length of arrow ?
Nitin Phadkule
Nitin Phadkule 2021 年 10 月 9 日
quiver(x,y,VectorX,VectorY,0)
add 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