Mathematica Defining a piecewise function in Mathematica

Summary
I can't define a piecewise function which reads data from a table as #
Hello everyone.

I am trying to do a 2D Shannon interpolation, but I cannot use a sinc because later on this expression goes in an optimization software that doesn't recognize it. I have defined my own version of sinc as:

sincC = Piecewise[{(Sin[Pi* #]/(Pi*(#))), # >= 1}, {1 - (#^2)/6 + (#^4)/120 - (#^6)/5040, # < 1}] & ;

The problem comes when I use the aforementioned sincC to construct the Shannon interpolation function.

shannonIPC[v_, w_] = Total[#3* sincC[(v - #1)/dDelta]*sincC[(w - #2)/dDelta] & @@@interpolatedData]

interpolatedData is a matrix of three columns and dDelta is a constant equal to 10. The error can be seen in the attached image, but it reads as
Piecewise:The first argument {(0.95493 Sin[1.0472 (-1.+v)])/(-1.+v),0.333333 (-1.+v)>=1} of Piecewise is not a list of pairs. and I am clueless about what to do.

Any advice is welcome.
Thanks for reading.
Regards.
 

Attachments

28,293
4,646
You need an extra pair of {...} to enclose all of the pieces of your piecewise function
 
You need an extra pair of {...} to enclose all of the pieces of your piecewise function
Thank you very much. That was it.
 

Want to reply to this thread?

"Defining a piecewise function in Mathematica" You must log in or register to reply here.

Related Threads for: Defining a piecewise function in Mathematica

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top