How to plot vector from data

3 次查看(过去 30 天)
Julien RUNTZ
Julien RUNTZ 2012-5-21
Hi,
I want to display 3D vectors. I got every channel in a different vector. Also Vec_X contains about 100 values and X is the axis. Vec_X(0) is the value that corresponds to X(0) Vec_X(n) to X(n).
And of course I also have Vec_Y and Y Vec_Z and Z.
What I want to do is display this as vectors. Plane XY, XZ, YZ and a 3D view of it. I started working with the matlab function quiver ( and quiver3 ). quiver(x,y,Vec_X,Vec_Y) but this doesn't work the way I want it to : It draws the vectors corresponding to the points (0,0) (1,1) (2,2) etc.. but (0,1) (0,2) etc are all missing.
Do you have an idea of what I could use ? The final objective is to find the point ( if it exists ) all these vectors are pointing at. So the graphic has to be readable.
Thanks for your help. If you have any question or if you don't understand what my objective is, I could paste some code lines :)

回答(3 个)

Sean de Wolski
Sean de Wolski 2012-5-21
Do you have a data point and corresponding vectors components for each of those (0,1), (0,2) etc.?
If you don't have points defined at these lcoations they won't be drawn and to get them you would have to interpolate.
More per comment/answers
doc meshgrid
use meshgrid to generate index matrices.

Julien RUNTZ
Julien RUNTZ 2012-5-21
hmm X is defined as smthg like X=-3:0.03:3; ( meters ) Y=-2:0.02:2; ( meters ) So X(1)=-3 and Vec_X(1) is the X component of my vector when X=-3. So Y(1)=-2 and Vec_Y(1) is the X component of my vector when Y=-2.
X,Y,Vec_X and Vec_Y all have the same size ( 1 x 100 or so ).
At the point (-3,-2)=(X(1),Y(1)) corresponds the vector (Vec_X(1),Vec_Y(1)).
So quiver uses every dual point (X(n),Y(n)) But to the point (X(3),Y(5)) corresponds (Vec_X(3),Vec_Y(5)) but those points/vectors don't exist on my final graph.
But all I really have is the global variables X,Y,Vec_X,Vec_Y

Julien RUNTZ
Julien RUNTZ 2012-5-21
Well
Looks like I found a way. I "manually" created the required vectors.
If x=[1 2 3] and y=[4 5 6] I created the new vectors X=[1 1 1 2 2 2 3 3 3] Y=[4 5 6 4 5 6 4 5 6] I also have all the points ( and did the same with the vectors ofc ).
But what bother me now is the amount of values I have. In this example I only took a size of 3. But my real problem involves 200. Which means I have 200² points and so 200² vectors ( over 40k ^^ ).
So the graphic is absolute hell. not readable at all. I managed to verify my results by patiently zooming in. But it's still not what I wanted.
Furthermore it's only in 2-D so far. I will finally have 201^3 points and corresponding vector...
Is there any way I could improve that ? By adding colors ? ( red for the biggest vector, blue for the smallest ). or anything else ?
  3 个评论
Walter Roberson
Walter Roberson 2012-5-21
Or to make your life even easier on yourself, ndgrid() instead of meshgrid()

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Vector Fields 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by