Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2002
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2002

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

Search the Archive

Re: elementwise vector scalar subtraction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg35643] Re: [mg35625] elementwise vector scalar subtraction
  • From: BobHanlon at aol.com
  • Date: Wed, 24 Jul 2002 02:06:06 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

In a message dated 7/23/02 2:14:31 AM, divinesaam at aol.com writes:

>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 ?
>

Clear[t];

t[x_] := Module[
      {v={0,1,1.5,2,2.5,4,6,8,10,15,20,30}},
      Join[{First[v]}, Rest[v]-(x/100.)]];

Clear /@ Table["tc"<>ToString[m], {m, 15, 30}];

Evaluate[Table[ToExpression["tc"<>ToString[m]], {m, 15, 30}]] =
 
    Table[t[15(1+m/15)], {m, 0, 15}];

tc15==t[15]

True

tc30==t[30]

True


Bob Hanlon
Chantilly, VA  USA


  • Prev by Date: Re: AW: Q: Simplify with "much less" assumptions
  • Next by Date: Re: help in generating a gaussian random variable
  • Previous by thread: Re: elementwise vector scalar subtraction
  • Next by thread: Re: elementwise vector scalar subtraction