How to create a vectorfield?

조회 수: 3 (최근 30일)
Peter
Peter 2012년 12월 11일
Hi everyone,
I would like to create a cube with vectors as elements, let's say a vector field of unit vectors e.i. length one. Is this possible and how is it done? Thanks for your input.
Best, Peter

답변 (2개)

Sean de Wolski
Sean de Wolski 2012년 12월 11일
편집: Sean de Wolski 2012년 12월 11일
doc meshgrid
doc quiver3
doc coneplot
Not sure of the details of what you want but it's likely some combination of the above.
More
Yes, you would use meshgrid for this:
The meshgrid would generate the coordinate matrices or rather the base of your vectors. Then you would need three more matrices of equal size that would be the components.
Here is an example that draws one unit vector at (0,0,0) pointing up and to the right with unit length:
s = fzero(@(s)1-sqrt((s^2)*3),1);
quiver3(0,0,0,s,s,s)
Now if you wanted it for the full thing, you could use s, repmat-ed to be the size of the output from meshgrid, etc.

Peter
Peter 2012년 12월 11일
Hi Sean,
I'm pretty sure this will become handy at some point but right now I'm not so worried about plotting a vector field but creating one. Or is meshgrid really what I'm looking for?
I'd like to have a let's say 10x10x10 matrix and fill each cell with vectors pointing upwards, length one.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by