Re: Manipulate piecewise functions,
- To: mathgroup at smc.vnet.net
- Subject: [mg107658] Re: [mg107643] Manipulate piecewise functions,
- From: Patrick Scheibe <pscheibe at trm.uni-leipzig.de>
- Date: Mon, 22 Feb 2010 03:08:22 -0500 (EST)
- References: <201002210924.EAA17172@smc.vnet.net>
Hi,
I hope I got your explanation right. You could define your plot-function
for one pair of params {a,p} and map it over your list a. So you get a
list of 6 plots which you can show:
a = {1, 2, 3, 4, 5, 6};
plotfunc[a_, p_] := Plot[
Piecewise[{{x - p, x - p < a}}, (x - p)^2], {x, 0, 20},
PlotRange -> {Automatic, {0, 100}},
PlotLabel -> ("Value for a is " <> ToString[a])];
Manipulate[
Grid[
Partition[Map[plotfunc[#, p] &, a], 3]]
, {p, 0, 20}]
my preferred solution would be to use /@ for map and make an anonymous
function for your plot
Manipulate[
Grid[
Partition[Plot[
Piecewise[{{x - p, x - p <= #}}, (x - p)^2], {x, 0, 20},
PlotRange -> {Automatic, {0, 50}},
PlotLabel -> ("Value for a is " <> ToString[#])] & /@ Range[6],
3]]
, {p, 0, 20}]
Cheers
Patrick
On Sun, 2010-02-21 at 04:24 -0500, Vedhas | sahdeV wrote:
> a = {1 2 3 4 5 6}
> The goal is to plot a piecewise function corresponding to each of "a"
> values, with manipulate where control variable is p, and the function
> for plot y versus x is:
> y=x-p for x-p<a, and (x-p)^2 for (x-p)>=a i.e. 6 plots getting
> manipulated simultaneously.
>
> I am new to Mathematica and this might be a naive question, but I
> couldn't find a solution through help documentation. I will appreciate
> if you can help!
>
> Thanks,
>
> Vedhas
>
- References:
- Manipulate piecewise functions,
- From: "Vedhas | sahdeV" <vedhas@gmail.com>
- Manipulate piecewise functions,