Wednesday, October 28, 2015

Ploting 3D Vectors in MATLAB

A three-dimensional quiver plot displays vectors with components (u,v,w)
at the points (x,y,z), where u, v, w, x, y, and z all have real (non-complex) values.

quiver3(x,y,z,u,v,w) plots vectors with directions determined by components
(u,v,w) at points determined by (x,y,z). The matrices x,y,z,u,v, and w must
all be the same size and contain the corresponding position and vector components.
Program
clc;
clear all;
close  all;


a = [2 3 5];
b = [1 1 0];
c = a+b;

starts = zeros(3,3);
ends = [a;b;c];

quiver3(starts(:,1), starts(:,2), starts(:,3), ends(:,1), ends(:,2), ends(:,3),0) % Zero is added for no %scaling
 axis equal

Sample Output