       Re: Plot in function

• To: mathgroup at smc.vnet.net
• Subject: [mg128435] Re: Plot in function
• From: Daniel <dosadchy at its.jnj.com>
• Date: Fri, 19 Oct 2012 02:42:43 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net

```>
> I would like to make a function that plots a variable
> over a parameter range. I tried:
>
> test[f_, sol_] :=
>  Table[Plot[
> f /. DeleteCases[sol, i], {i[], 0.9 i[], 1.1
> 1.1 i[]}], {i,
>    sol}]
>
> But this gives the error:
>
> test[x^2 + y^2, {x -> 0, y -> 0}]
>
> During evaluation of In:= Plot::write: Tag Part
> in i[] is Protected. >>
>
> I see that i cannot define a part in the variable of
> a plotfunction, but also if I first assign i[] to
> a variable, I get a problem with the bounds.
>
> test[f_, sol_] :=
>  Table[a = i[];
> Plot[f /. DeleteCases[sol, i], {a, 0.9 i[], 1.1
> .1 i[]}], {i,
>    sol}]
>
> I don't know of a good solution. Thanks in advance.
>

First, the expression {i[], 0.9 i[], 1.1 i[]} is not good in your case as both limits evaluate to 0.
Other that this, you're missing Evaluate[]:

test[f_, sol_] :=
Table[Plot[f /. DeleteCases[sol, i], {i[], i[] - 1, i[] + 1}//Evaluate], {i, sol}]

test[x^2 + y^2, {x -> 0, y -> 0}] - draws 2 plots

```

• Prev by Date: Re: Sum elements in a list with conditions
• Next by Date: Re: Mathematica code for Kepler's radial velocity equation?
• Previous by thread: Plot in function
• Next by thread: Re: Plot in function