Re: piecewise plot
- To: mathgroup at smc.vnet.net
- Subject: [mg78917] Re: [mg78854] piecewise plot
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Thu, 12 Jul 2007 05:29:32 -0400 (EDT)
- Reply-to: hanlonr at cox.net
eq1 = 0*UnitStep[x, 10 - x];
eq2 = 1*UnitStep[x - 10, 20 - x];
eq3 = 0*UnitStep[x - 20, 30 - x];
eq4 = -0.5*UnitStep[x - 30, 40 - x];
eq5 = 0*UnitStep[x - 40, 50 - x];
eq6 = 2*UnitStep[x - 50, 60 - x];
Plot[{eq1, eq2, eq3, eq4, eq5, eq6}, {x, -5, 65},
ColorFunction -> "Rainbow", Filling -> Axis]
i[x_] := Piecewise[{{1, 10 < x <= 20},
{-0.5, 30 < x <= 40}, {2, 50 < x <= 60}}];
Plot[i[x], {x, -5, 65},
ColorFunction -> "Rainbow", Filling -> Axis]
Bob Hanlon
---- Jake Trexel <jtrexel at ix.netcom.com> wrote:
> I would like to plot something like this with version 6
> At time 0 to 10 the current is 0, at time 10 to 20 it is 1, time 20 to 30 it
> is 0, time 30 to 40 it is -0.5, time 40 to 50 it is 0, then at time 50 to 60
> it is +2.
> I would like to break each of these up into something like this eq1:= for 0
> to 10, eq2 := 10 to 20 and so on. Then I want to combine the equations into
> a plot. Then I would like to fill in the different sections with different
> colors.
> I will then go one with another eq. that uses these results and filled in
> areas to show how they interact. I will worry about this after my first
> question.
> Can some one help me?
> thanks
> Prof. Jake
> Former Professor of Mechanical Engineering
>
>