Department of Applied Mathematics at the University of Colorado at Boulder
University of Colorado at Boulder Search A to Z Campus Map University of Colorado at BoulderCU Search Links
Print this page

Add and Plot Vectors

07: Add and Plot vectors

Add two vectors (each of 7 elements), then plot the values of the result

u = (3,0,1,4,2,6,4)
v = (1,2,3,4,5,6,7)
plot w = u + v

Mathematica:

u =
v = Range[1,7]
w = u+v;
ListPlot[w]

Matlab:

u = [3,0,1,4,2,6,4]
v = linspace(1,7,7)
w = u+v
plot(w)

Maple:

with(LinearAlgebra):
u := Vector[row]([3,0,1,4,2,6,4]);
v := Vector[row](7, n->n);
w := u+v;
plot( [seq([i,w[i]],i=1..7)] );

IDL:

u = [3,0,1,4,2,6,4]
v = findgen(7)+1
w = u+v;
plot, w