2
$\begingroup$

I have a list of values called EDFh3. This contained values which are partitioned by 3 where it is in the format

EDFh3 = {{value, lowerbound condition, upperbound condition},{},{},...}
Piecewise[{{#1, #2 <= x < #3}}] & @@@ EDFh3

I am trying to create a piecewise function that contains all of the values in EDFh3 into one piecewise function. Instead when I apply it to the Piecewise function I get a list of piecewise functions. Is there any way to combine piecewise function? Alternatively is there a way to edit the code above to produce one piecewise function initially.

$\endgroup$
1
  • 1
    $\begingroup$ Piecewise[{#1, #2 <= x < #3} & @@@ EDFh3] You just need to move your closing ] (and remove the outer list). $\endgroup$ Mar 6, 2017 at 16:09

1 Answer 1

3
$\begingroup$
Piecewise[{#1, #2 <= x < #3} & @@ # & /@ EDFh3]

or

Piecewise[{#[[1]], #[[2]] <= x < #[[3]]} & /@ EDFh3]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.