How to create an array of vectors corresponding to a particular point
Mostrar comentarios más antiguos
Hi everyone,
I have been working on this problem for a while and have found no feasible way of doing it.
I have a sphere of points defined by the coordinates X,Y and Z. For each of the point I would like to have a set of complete (i.e. vectors at each X,Y and Z point) vectors that points toward it. For example I can do this quite easily for one point:
R=22; phi=linspace(0,pi,50); theta=linspace(-pi/2,pi/2,50);
[phi,theta]=meshgrid(phi,theta);
X=R*sin(phi).*cos(theta); Y=R*sin(phi).*sin(theta); Z=R*cos(phi);
P1x=22;P1y=0;P1z=0;
X1=P1x-X; Y1=P1y-Y; Z1=P1z-Z;
quiver3(X,Y,Z,X1,Y1,Z1)
As you can see this produces an array of vectors that points towards one point. I would like to do this for every point on the sphere. I'm unsure how to do this though because as I understand it you cannot have an array of arrays in matlab.
If anyone has any ideas they would be appreciated, thanks, John.
1 comentario
Guillaume
el 2 de Feb. de 2016
You can have an array of arrays in matlab, either using a cell array, or if all the arrays are the same size by concatenating them along an extra dimension.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Surfaces, Volumes, and Polygons en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!