RE: matrix operations
- To: mathgroup at smc.vnet.net
- Subject: [mg46366] RE: [mg46329] matrix operations
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Mon, 16 Feb 2004 23:41:52 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: paolo tarpanelli [mailto:tarpanelli at libero.it] To: mathgroup at smc.vnet.net >Sent: Sunday, February 15, 2004 4:20 AM >To: mathgroup at smc.vnet.net >Subject: [mg46366] [mg46329] matrix operations > > >If I have a matrix > >a={x[[1,1]],x[[1,2]],...,x[[1,n]]} > {x[[2,1]],x[[2,2]],...,x[[2,n]]} > . > . > . > {x[[m,1]],x[[m,2]],...,x[[m,n]]} > >how can I compute the difference between any element and the >previous for each column : > >aa={x[[2,1]]-x[[1,1]], x[[2,2]]-x[[1,2]],...,x[[2,n]]-x[[1,n]]} > {x[[3,1]]-x[[2,1]], x[[3,2]]-x[[2,2]],...,x[[3,n]]-x[[2,n]]} > . > . > . > {x[[m,1]]-x[[m-1,1]],x[[m,2]]-x[[m-1,2]],...,x[[m,n]]-x[[m-1,n]]} > >--------------------------------------------------------------- >--------------------------------------- > >I built this code but it does not work > >r=Array[0,{m,n}] >For[j=1,j=n,j++ > r[[i,j]]=Table[a[[i+1,j]]-a[[i,j]],{i,1,m-1,1}]] > >thanks > >Paolo > >---------------- > e.g.: a = Array[x, {5, 4}]; Subtract @@@ Reverse /@ Partition[a, 2, 1] // TableForm (#2 - #1 &) @@@ Partition[a, 2, 1] // TableForm -- Hartmut Wolf