MathGroup Archive 2002

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: elementwise vector scalar subtraction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35658] Re: [mg35625] elementwise vector scalar subtraction
  • From: "Julio Vera" <jvera at adinet.com.uy>
  • Date: Wed, 24 Jul 2002 02:06:48 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Oscar,

Here's my solution.

In[1]:=  t = {0, 1, 1.5, 2, 2.5, 4, 6, 8, 10, 15, 20, 30}

Out[1]= {0,1,1.5,2,2.5,4,6,8,10,15,20,30}

Define the first, last, and increment of the numbers to be substracted.

In[2]:= first=.15

           last=.3

          increm=.05

Out[2]= 0.15

Out[3]= 0.3

Out[4]= 0.05

Define a list of elements to be substracted, for each value.

In[5]:= =
tc=Table[Table[first-increm+increm*i,{Length[t]-1}],{i,(last-first)/increm+1}]/.{a_/;NumberQ[a],b__}=AE{0,a,b}

Out[5]= 
{{0,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15,0.15},{0,0.2,0.2,0.
2,0.2,0.2,0.2,0.2,0.2,0.2,0.2,0.2},{0,0.25,0.25,0.25,0.25,0.25,0.25,0.25,
0.25,0.25,0.25,0.25},{0,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3}}

Substracting each tc[[i]] from t, we get each of the lists tc you were 
looking for.

tt[[1]] is your tc15, and so on.

In[6]:= 
tt=Table[Table[t[[i]]-tc[[j,i]],{i,Length[t]}],{j,Length[tc]}]

Out[6]= 
{{0,0.85,1.35,1.85,2.35,3.85,5.85,7.85,9.85,14.85,19.85,29.85},{0,0.8,1.3
,1.8,2.3,3.8,5.8,7.8,9.8,14.8,19.8,29.8},{0,0.75,1.25,1.75,2.25,3.75,5.75
,7.75,9.75,14.75,19.75,29.75},{0,0.7,1.2,1.7,2.2,3.7,5.7,7.7,9.7,14.7,19.
7,29.7}}

Julio

 --------------------------------

Dear Colleagues,

I have a t-vector

t = {0, 1, 1.5, 2, 2.5, 4, 6, 8, 10, 15, 20, 30};

I want to subtract 0.15 from each element except the first to get

tc15 = {0, 1 - 0.15, 1.50 - 0.15, 2 - 0.15, 2.5 - 0.15, 4 - 0.15, 6 -
0.15, 8 - 0.15, 10 - 0.15, 15 - 0.15, 20 - 0.15, 30 - 0.15};

I then want to subtract 0.20 to get

tc20 = {0, 1 - 0.20, 1.50 - 0.20, 2 - 0.20, 2.5 - 0.20, 4 - 0.20, 6 -
0.20, 8 - 0.20, 10 - 0.20, 15 - 0.20, 20 - 0.20, 30 - 0.20};

Is there a way to automate this process for n subtractions from 0.15
to 0.30 to yield individual t-vectors for tc15 through tc30 ?

With Much Appreciation,

Oscar







  • Prev by Date: RE: elementwise vector scalar subtraction
  • Next by Date: Re: Problem using a loop to generate data for Point function
  • Previous by thread: RE: elementwise vector scalar subtraction
  • Next by thread: Re: elementwise vector scalar subtraction