how to graph vector fields containing scalar

I'm trying to graph some vector fields .
F(x,y,z)-<1,2,z>
F(x,y)=<0.3, -0,4)
my code is look like this
>> [x,y,z]=meshgrid(-2:2,-2:2,-2:2);
>> u=1;
>> v=2;
>> s=z;
>> quiver(x,y,z,u,v,s)
Second one is similar.
>> [x,y,]=meshgrid(-2:2,-2:2);
>> u=0.3;
>> v=-0.4;
>> quiver(x,y, u,v )
I tried to use ones(size(v)) function but it doens't work.
Any help would be helpful. Thank you

답변 (1개)

Monisha Nalluru
Monisha Nalluru 2020년 11월 17일

1 개 추천

quiver used to for vector plot
The input arguments X,Y,U,V all should be of same size
In the above problem u,v should be same size of x,y
As an example
[x,y,]=meshgrid(-2:2,-2:2);
u=ones(size(x));
v=ones(size(x)) * 2;
quiver(x,y,u,v)
And inorder to increase the arrow length use scale argument
quiver(x,y,u,v,2) % scale the arrow length to 2 units

댓글 수: 1

@수정 이 In first case, it is a 3D plot , so you require quiver3 plot instead of 2D quiver function
[x,y,z]=meshgrid(-2:2,-2:2,-2:2);
u=ones(size(x));
v=ones(size(x)) * 2;
w = z;
s = 'r'; % color
quiver3(x,y,z,u,v,w,s)

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

질문:

2020년 11월 14일

댓글:

2024년 8월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by