Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Does Mathematica have a mapping function like scipy or any of the multidimensional ones?

By this I mean something like mapping $[1,100]$ onto $[7,20]$ for example.

Looking at Interpolate I only see interpolation with regards to estimating a line given points.

To make it more clear I mean a simple example using a linear mapping would be $[0,512]$ onto $[0,10]$ would give 5 for a value of 256.

Edited: (Comments added for greater precision):

  1. What would make the question more clear? An example would be reading in a sensor that gives values on $[0,256]$ and using those to operate say a servo which accepts values on $[0,10]$

  2. in this scale that is exactly what I'm looking for! thanks. Is it possible to use mappings of other orders, ex. a normal distribution or a quadratic mapping? This being a linear mapping. –

share|improve this question
1  
I don't understand what your asking for. –  rcollyer Apr 10 '12 at 1:13
2  
Do you mean splines? reference.wolfram.com/mathematica/guide/Splines.html –  Vitaliy Kaurov Apr 10 '12 at 1:55
    
Are you looking for Rescale[256, {0,512}, {0,10}] (==> 5)? –  Brett Champion Apr 10 '12 at 2:22
    
@BrettChampion in this scale that is exactly what I'm looking for! thanks. Is it possible to use mappings of other orders, ex. a normal distribution or a quadratic mapping? This being a linear mapping. –  Eiyrioü von Kauyf Apr 10 '12 at 2:25
1  
The reason why your question was unclear is that you mention interpolation when you need a linear transformation (they're unrelated) and that originally you didn't say at all that you need a linear transformation. There are of course infinitely many (non-linear) mappings from interval $[a,b]$ to interval $[c,d]$. –  Szabolcs Apr 10 '12 at 6:57

1 Answer 1

Your question isn't very clear, but I think you need the Rescale function, especially its 3 argument form:

Rescale[#, {1, 100}, {7, 20}] & /@ Range[1, 100, 5] // N
(* Out[1]= {7., 7.65657, 8.31313, 8.9697, 9.62626, 10.2828, 10.9394, 11.596, 12.2525, 12.9091, 
    13.5657, 14.2222, 14.8788, 15.5354, 16.1919, 16.8485, 17.5051, 18.1616, 18.8182, 19.4747}
 *)
share|improve this answer
    
what would make the question more clear? An example would be reading in a sensor that gives values on [0,256] and using those to operate say a servo which accepts values on [0,10]. –  Eiyrioü von Kauyf Apr 10 '12 at 2:23
    
@EiyrioüvonKauyf Then Rescale is exactly what you want. You should also look into Clip to use along with this if you don't want to give out of bound values to your servo. –  rm -rf Apr 10 '12 at 2:59
    
@R.M Rescale[] is what I thought about when reading the question, but I agree it wasn't evident. Author, you might want to edit your question adding the precisions you gave in the comments! –  CHM Apr 10 '12 at 3:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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