How to create an array of vectors corresponding to a particular point
이전 댓글 표시
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
Guillaume
2016년 2월 2일
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.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Surfaces, Volumes, and Polygons에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!