From: Peter Breitfeld on 17 Apr 2010 06:04 When trying to find an answer to mercia's post I came into this stepFunction::usage = "stepFunktion[x,{x1,x2,...,xn},valfunc] generates a \ stepfunction using Piecewise from List xi, where x1<x_2<...xn valfunc is a function of two parameters to calculate the value \ inside Interval [\!\(\*SubscriptBox[\"x\", \ \"i\"]\),\!\(\*SubscriptBox[\"x\", RowBox[{\"i\", \"+\", \"1\"}]]\)]." ; stepFunction[x_, mesh_List, valfunc_] := Module[{args, bed, werte, part}, part = Partition[mesh, 2, 1]; werte = valfunc @@@ part; bed = (#1 <= x < #2) & @@@ part; args = Transpose[{werte, Flatten[bed]}]; Evaluate[Piecewise[Evaluate(a)args]]] treppe[y_]=stepFunction[y, mesh,(#1+#2)/2&] I get the warning: Piecewise::pairs: The first argument of args$706 of Piecewise is not a list of pairs. But the output is ok and test like treppe /@Range[1,20] show the right result. A Plot works fine What's wrong in my code to produce the message? $Version= 7.0 for Mac OS X x86 (64-bit) (February 19, 2009) -- _________________________________________________________________ Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
|
Pages: 1 Prev: Question on replacementFunction Next: sqlite database connection |