Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #9085

Re: Map onto a column

From dr DanW <dmaxwarren@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Map onto a column
Date 2012-03-16 11:35 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jjv8ir$phs$1@smc.vnet.net> (permalink)
References <jjmv20$cfr$1@smc.vnet.net>

Show all headers | View raw


MapAt needs a level specification.  I posted this a few years ago, but here it is again:

MapAtLevel::usage = "MapAtLevel[\!\(\*
StyleBox[\"f\", \"TI\"]\),\!\(\*
StyleBox[\"expr\", \"TI\"]\),\!\(\*
StyleBox[\"n\", \"TI\"]\),\!\(\*
StyleBox[\"levelspec\", \"TI\"]\)] applies \!\(\*
StyleBox[\"f\", \"TI\"]\) to the element at position \!\(\*
StyleBox[\"n\", \"TI\"]\) at level \!\(\*
StyleBox[\"levelspec\", \"TI\"]\) in \!\(\*
StyleBox[\"expr\", \"TI\"]\)."

MapAtLevel[f_, expr_, n_, levelspec_: {1}] := 
 Map[MapAt[f, #, n] &, expr, levelspec - 1] 

I have this in a package of useful utilities I load in my init.m.

A typical use is when I want to plot data on a Decibel scale:

data = Table[{i, 10^(10.*(i/20))}, {i, 5}];
ListPlot[MapAtLevel[20*Log10[#1] & , data, 2, {2}], Joined -> True]

Enjoy,
Daniel

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Map onto a column Sly Pandemia <slypandemia@gmail.com> - 2012-03-13 08:04 +0000
  Re: Map onto a column Ray Koopman <koopman@sfu.ca> - 2012-03-14 05:45 +0000
  Re: Map onto a column JasonE <ebaughjason@gmail.com> - 2012-03-14 05:47 +0000
  Re: Map onto a column roby <roby.nowak@gmail.com> - 2012-03-14 05:48 +0000
  Re: Map onto a column dr DanW <dmaxwarren@gmail.com> - 2012-03-16 11:35 +0000

csiph-web