Re: Data Extraction from List {{x1,y1}..{xn,yn}}where ##<x<##
- To: mathgroup@smc.vnet.net
- Subject: [mg11717] Re: [mg11694] Data Extraction from List {{x1,y1}..{xn,yn}}where ##<x<##
- From: Bob Hanlon <BobHanlon@aol.com>
- Date: Thu, 26 Mar 1998 03:08:45 -0500
lowerBound = 1; upperBound = 2;
data = Table[{Random[Real,
{lowerBound - 1, upperBound + 1}], Random[]}, {10}]
{{2.211960315473586, 0.1998931999852455},
{0.1011631544045859, 0.5000081876699439},
{0.7533173398010588, 0.6993519784841843},
{1.943461973402654, 0.5124762240130565},
{0.7567411956659391, 0.3805908015753625},
{0.8485908733012134, 0.7626323135620092},
{1.869675955305686, 0.1739173636902784},
{0.7651252241562137, 0.9579908196346858},
{2.381361939427495, 0.2404805028723822},
{1.21709689161098, 0.6421971666935029}}
Select[data, #1[[1]] >= lowerBound &&
#1[[1]] <= upperBound & ]
{{1.943461973402654, 0.5124762240130565},
{1.869675955305686, 0.1739173636902784},
{1.21709689161098, 0.6421971666935029}}
Bob Hanlon
In a message dated 3/22/98 12:52:56 AM, koehlerc@execpc.com wrote:
>How might I extract a range of {x,y}from a list of data, so that I can
>perform a linear fit between the point that meet the criterion of being
>bewteen x_n and x_m.
>
>In other words, fit a line to a part of the data that has #1<x<#2.
>
>I have attempted to use the Select function but it requires me to
>Flatten the data list first? And it results in giving me a list of just
>the x values not the {x,y} pairs.