[Date Index]
[Thread Index]
[Author Index]
# Re: Why doesn't this work ?
Andreas Keese wrote:
> Look at this:
>
> This works:
> Clear[S1];
> S1=Sin[x];
> Plot[S1, {x, 0, 3}]
>
> But why doesn't it work with more than one functions ?
>
> Clear[S2];
> S2={Sin[x],Cos[x]};
> Plot[S2, {x, 0, Pi}]
>
> gives an error - Mathematica complains that S2 is not a machine-size
> number.
>
> BTW: I don't want S2 to be pattern cause I want to use this as follows:
>
> Clear[S,dx,S3,x];
> S[x_]:={Sin[x/dx], Cos[x/dx], Sin[2*x/dx]};
> S3=Evaluate[S[x] /. dx -> 2];
> Plot[S3, {x, 0, Pi}];
Andreas,
S2={Sin[x],Cos[x]};
Plot[S2, {x, 0, Pi}]
does not work because Mathematica does not evaluated S3 and so find out
that it must allow for a list of functions *before* it feeds in values.
S2={Sin[x],Cos[x]};
Plot[Evaluate[S2], {x, 0, Pi}]
works becaues the first thing that is done is to evaluate S2 to
{Sin[x],Cos[x]} so that Mathematica gets the clue.
Your last example can be reorgnised so as to work:
Clear[S,dx,S3,x];
S[x_]:={Sin[x/dx], Cos[x/dx], Sin[2*x/dx]};
S3=S[x] /. dx -> 2; (*Evaluate not needed*)
Plot[Evaluate[S3], {x, 0, Pi}];
--
Allan Hayes
Training and Consulting
Leicester, UK
hay@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642
Prev by Date:
**Re: HELP: How to increase the resolution of .GIF images when importing to HTML ?**
Next by Date:
**Re: How to draw full text in graphics**
Prev by thread:
**Re: Why doesn't this work ?**
Next by thread:
**Re: Why doesn't this work ?**
| |