// Date: June 13, 2009 // Subject: Vector plot //Dear Jerry Nelson //The following is my subroutine for plottin vectors. // loc is the coordinate where tail of the vector is located // r is the vector // th is theta parameter of plot3d for viewing // al is alpha parameter of plot3d for viewing function ccoPlotVector(loc,r,th,al) plot3d([loc(1,1); loc(1,1)+r(1,1)],.. [loc(1,2); loc(1,2)+r(1,2)],.. [loc(1,3); loc(1,3)+r(1,3)],.. theta=th, alpha=al); endfunction x=[2, 4, 9] // your sample vector y=[1, 3, 5] // your sample vector org=[0,0,0];th=30; al=50;clf; subplot(2,2,1); xtitle("x and y at origin"); ccoPlotVector(org,x,th,al); ccoPlotVector(org,y,th,al); subplot(2,2,2); xtitle("x at origin y on x"); ccoPlotVector(org,x,th,al); ccoPlotVector(x,y,th,al); c=x+y subplot(2,2,3); xtitle("x at origin y on x and c as sum"); ccoPlotVector(org,x,th,al); ccoPlotVector(x,y,th,al); ccoPlotVector(org,c,th,al); d=x-y;th=22;al=53; subplot(2,2,4); xtitle("x at origin y on x and d as difference"); ccoPlotVector(org,x,th,al); ccoPlotVector(org,y,th,al); ccoPlotVector(y,d,th,al); //Once plotted I use the rotate bottom to view the vector. //Then I note down the theta and alpha readings at the //bottom of the plot window. // I hope this helps. Let me know if you are satisfied. //Eng'r Celso B. Co, Ph.D, PECE //Department of Electronics, Computers, and Communication //Engineering //Loyola Schools of Science and Engineering //Ateneo De Manila //Loyola Height //Diliman Quezon City 1108 //Philippines //email: celso.co@gmail.com