Re: Manipulating Solution List from NDSolve

• To: mathgroup at smc.vnet.net
• Subject: [mg112732] Re: Manipulating Solution List from NDSolve
• From: Albert Retey <awnl at gmx-topmail.de>
• Date: Tue, 28 Sep 2010 06:50:47 -0400 (EDT)
• References: <i7seo7\$ppq\$1@smc.vnet.net>

```Am 28.09.2010 12:07, schrieb blamm64:
> Hi,
>
> Given:
>
> var = {a, b, c} (variables input to NDSolve)
>
> and the output solution list
>
> sol = {{a -> 1, b -> 2, c -> 3}}
>
> (I'm just using 1, 2, and 3 instead of InterpolatingFunction).
>
> Do the following:
> I would like to create a list, say "solList" that is
>
> solList = {as,bs,cs}
>
> using the list var, instead of typing it out by hand.
>
> Next, with solList in hand, I would like to end up with the equivalent
> to
>
> {as=1,bs=2,cs=3}.
>
> but using only solList, var, and sol lists.
>
> All that is equivalent to doing
>
> {as,bs,cs} = var /. sol[[1]] .
>
> But I would like to avoid typing it all out by hand because the actual
> list var is a lot longer.
>
> With solList in hand and doing
>
> solList = var /. sol[[1]]
>
> of course does not work.
>
> I created a notebook and defined
>
> var = {a,b,c};
> sol = {{a -> 1, b -> 2, c -> 3}};
> solList = {as, bs, cs}
>
> (giving up on trying to create solList using var), and started trying
> different methods, all failing to get the equivalent of
>
> {as,bs,cs} = var /. sol[[1]] .
>
> without typing it all in by hand.

setting as,bs,cs,... is relatively simple, if they are not yet having
values:

Evaluate[solList] = var /. sol[[1]]

it is somewhat more complicated to clear the definitions once they have
been made, and you have to do so for your second run. Here is one
possibility:

ReleaseHold[
Apply[Clear, Extract[OwnValues[solList], {1, 2}, Hold], {1}]
]

hth,

albert

```

• Prev by Date: FinancialData[] and ISIN
• Next by Date: Re: Test for dialog existence
• Previous by thread: Manipulating Solution List from NDSolve
• Next by thread: Re: Manipulating Solution List from NDSolve