Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14355 > unrolled thread

Re: how to generate piecewise function from two lists

Started byRay Koopman <koopman@sfu.ca>
First post2013-04-28 09:17 +0000
Last post2013-04-30 08:17 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Re: how to generate piecewise function from two lists Ray Koopman <koopman@sfu.ca> - 2013-04-28 09:17 +0000
    Re: how to generate piecewise function from two lists S <dsalman96@gmail.com> - 2013-04-30 08:17 +0000

#14355 — Re: how to generate piecewise function from two lists

FromRay Koopman <koopman@sfu.ca>
Date2013-04-28 09:17 +0000
SubjectRe: how to generate piecewise function from two lists
Message-ID<klipf6$121$1@smc.vnet.net>
Piecewise[{#1, #2[[1]] < x < #2[[2]]}& @@@ Transpose@{f,Partition[r,2,1]}]

On Sat, Apr 27, 2013 @ 10:00 PM, S <dsalman96@gmail.com> wrote:
> Hello
> 
> Suppose we have two lists
> f={a,b}
> r={0,1,2)
> 
> In general, the lengths of f and r can vary but the length of f is always 1 less than length of r.
> 
> Using the lists f and r, I want to define a piecewise function of the form:
> 
> Piecewise[{{a,0<x<1},{b,1<x<2}}] i.e., having the form
> 
> Piecewise[{{f[[1]],r[[1]]<x<r[[2]]},{f[[2]],r[[2]]<x<r[[3]]}}]
> 
> Is there a way to define a piecewise function using f and r for the general case, as described above.
> 
> Thanks
> 
> S

[toc] | [next] | [standalone]


#14359

FromS <dsalman96@gmail.com>
Date2013-04-30 08:17 +0000
Message-ID<klnuna$g25$1@smc.vnet.net>
In reply to#14355
Thank you. It works perfectly.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web