# Perform calculation on several sublists using Map

I am trying to perform a calculation on a list containing sublists. More exact: The x-axis values are time data, progressing from zero, the y-axis data are data points, which I want to normalize. I want the y data to have their minimum at zero. Therefore, I look for the smallest y value in each sublist and add or subtract (depending if it is positive or negative) from all other y values of that sublist. I want to perform the calculation for all sublists. I think I haven't quite understood what the Slot (#) exactly does?!

I post here just an example list illustrating my problem, since the real list is very long.

My approach:

list={{{0,-0.1},{1,0.5},{2,0.7},{3,1.2},{4,0.6},{5,0.5},{6,1.3}},{{0,0.1},{1,0.5},{2,0.3},{3,0.7},{4,0.8},{5,1.1},{6,1.2}}}

list//{#[[1]],(#[[2]]-Min[#[[All,2]]])}&/@#&


This approach gives the following errors:

Part::partw: Part 1 of {} does not exist. >>

Part::partw: Part 2 of {} does not exist. >>

Part::partw: Part 1 of {} does not exist. >>

General::stop: Further output of Part::partw will be suppressed during this calculation. >>

• You might be interested in Rescale[]. – J. M. will be back soon Aug 27 '15 at 11:27
• Cool! I didn't know that command. But just out of interest, is there a way to solve my problem with something similar I tried? – Niki Aug 27 '15 at 11:31

First of all, your code does not return an error on my machine.

Second, using "something similar to what you tried", you might want to do

Transpose[{#[[All, 1]], #[[All, 2]] - Min[#[[All, 2]]]}] & /@ list


f[u_] := Module[{a, b}, {a, b} = Transpose@u;

f/@list yields: