Re: Why doesn't this work ?
- To: mathgroup@smc.vnet.net
- Subject: [mg10422] Re: [mg10381] Why doesn't this work ?
- From: jpk@max.mpae.gwdg.de
- Date: Tue, 13 Jan 1998 02:07:23 -0500
Hi Andreas
Plot has the attribute HoldAll. So:
> Look at this:
>
> This works:
> Clear[S1];
> S1=Sin[x];
> Plot[S1, {x, 0, 3}]
>
Matheamtica see one single symbol S1 and assumes it has to plot one
function. S1 gets evaluated and evaluates to Sin[x] -- all works fine.
> But why doesn't it work with more than one functions ?
>
> Clear[S2];
> S2={Sin[x],Cos[x]};
> Plot[S2, {x, 0, Pi}]
Again Mathematica see one single symbol and assumes S2 will return one
value. Now S2 gets evaluated and evaluates to a pair of functions --
but now it is to late to fall back from the assumption of one single
argument and You get an error message.
To Help You out -- Just put a Evaluate[S1] to Your first
Plot[]-argument. Than S2 is evaluated first
Plot[Evaluate[S2],{x,0,Pi}]
to
Plot[{Sin[x],Cos[x]},{x,0,Pi}]
and Mathematica can reconize that more than one function is to be
plotted. Hope that helps
Jens