Re: multiple plots from a list of parameters?
- To: mathgroup at smc.vnet.net
- Subject: [mg64491] Re: multiple plots from a list of parameters?
- From: albert <awnl at arcor.de>
- Date: Sun, 19 Feb 2006 05:35:59 -0500 (EST)
- References: <dt6l0m$njq$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
1.156 wrote:
> Apparently I finally stumbled into a way to invert a function p[f,L] on
> which I recently posted. But after a lot of trying I can't seem to
> stumble my way into the next step. The code below works:
>
> p[f_,L_] =: (defined)
>
> result16 := FindRoot[p[f, L] == 1600, {f, 0.5}];
> result12 := FindRoot[p[f, L] == 1200, {f, 0.5}];
> result08 := FindRoot[p[f, L] == 800, {f, 0.5}];
> result04 := FindRoot[p[f, L] == 400, {f, 0.5}];
>
> pL16 = Plot[f /. result16 // Evaluate, {L, 0.2, 10}]
> pL12 = Plot[f /. result12 // Evaluate, {L, 0.2, 10}]
> pL08 = Plot[f /. result08 // Evaluate, {L, 0.2, 10}]
> pL04 = Plot[f /. result04 // Evaluate, {L, 0.2, 10}]
>
> Show[pL16,pL12,pL08,pL04]
>
> I end up with 4 plots. Even I can tell this is crude and no way to do
> business. I need to be able to use a list={1600,1200,800,400} and get
> these 4 (or n plots) plots done in less than n sets of statements. All
> my attempts to use the list fail. Can someone give me some syntax that
> will do this? Many thanks, Rob
(just my dummy function for testing)
p[f_, L_] := f^2 + 20*Sin[L];
numbers = {400, 800, 1200, 1600};
result[n_, (L_)?NumericQ] := f /. FindRoot[p[f, L] == n, {f, 0.5}];
plot[n_] := Plot[result[n, L], {L, 0.2, 10}];
allplots = Map[plot,numbers];
Show[allplots];
If you are interested in the last combined plot only you could use instead:
allplots = Block[{$DisplayFunction=Identity},Map[plot,numbers]];
Show[allplots]
If you want to look at a single value:
result[800,0.76]
You will learn a lot of useful things if you look up everything you don't
understand in the help-browser :-)
albert