Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #3128 > unrolled thread
| Started by | Dominic Wörner <dominic.woerner@mpi-hd.mpg.de> |
|---|---|
| First post | 2011-06-16 10:23 +0000 |
| Last post | 2011-06-16 10:23 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Problem with Position Dominic Wörner <dominic.woerner@mpi-hd.mpg.de> - 2011-06-16 10:23 +0000
| From | Dominic Wörner <dominic.woerner@mpi-hd.mpg.de> |
|---|---|
| Date | 2011-06-16 10:23 +0000 |
| Subject | Re: Problem with Position |
| Message-ID | <itcljq$gte$1@smc.vnet.net> |
Thank you Bob. This works perfectly in my case
Best,
Dominic
Am 16.06.2011 um 10:00 schrieb Bob Hanlon:
>
> Perhaps the numbers have more decimal places than what is displayed =
and you
> need to round to the precision of the index key.
>
> choices = {0.123456, 0.654321, 0.785398};
>
> data = Table[{
> RandomChoice[choices] + 10^-7*Random[],
> RandomReal[], RandomReal[]}, {10}];
>
> Flatten@
> Position[N[Round[data[[All, 1]], 10^-6]],
> 0.785398]
>
> {2, 5, 6, 9}
>
> Flatten@
> Position[N[Round[data[[All, 1]], 10^-6]], #] & /@
> choices
>
> {{1, 3, 4, 8}, {7, 10}, {2, 5, 6, 9}}
>
> Alternatively,
>
> Flatten@
> Position[data[[All, 1]],
> _?(Abs[# - 0.785398] < 10^-6 &)]
>
> {2, 5, 6, 9}
>
> Table[
> Flatten@Position[data[[All, 1]],
> _?(Abs[# - c] < 10^-6 &)],
> {c, choices}]
>
> {{1, 3, 4, 8}, {7, 10}, {2, 5, 6, 9}}
>
>
> Bob Hanlon
>
> ---- "Dominic W=C3=B6rner" <dominic.woerner@mpi-hd.mpg.de> wrote:
>
> =============
> Hi,
>
> I have to import data from a csv file. And I get a structure =
data[[rows]] ={first, second,...}.
> Now I want to find the rows in which, say the first entry has a =
specific values.
> By just looking at the data there are for example entries with value =
0.785398.
> But when I try Flatten@Position[data[[All,1]],0.785398] or with =
ToString[0.785398] I just get {}
>
> What's the problem here?
>
> Best,
> Dominic
>
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web