Re: Problem using Evaluate[] inside a Plot command. 5.1
- To: mathgroup at smc.vnet.net
- Subject: [mg54268] Re: Problem using Evaluate[] inside a Plot command. 5.1
- From: Maxim <ab_def at prontomail.com>
- Date: Mon, 14 Feb 2005 21:51:26 -0500 (EST)
- References: <cu78ub$me9$1@smc.vnet.net> <cumor4$3rc$1@smc.vnet.net> <cup5b7$drp$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On Mon, 14 Feb 2005 03:19:03 +0000 (UTC), Nasser Abbasi <nma at 12000.org> wrote: > D Herring wrote: > >> Hi Nasser, >> >> Maybe Evaluate[OutputResponse[sys,UnitStep[t], t]] is returning a value >> which needs to be Evaluate[]d again before it can be plotted? >> >> I've never had your problem (don't even have the control toolbox), but >> maybe >> >> Plot[{t2, Evaluate[Evaluate[OutputResponse[sys,UnitStep[t], t]]]}, >> {t, 0, 3}, PlotRange -> All] >> >> might work? >> >> Your error message, "plot::plnr: .... is not a machine-size real >> number at t=...." usually indicates the need to Evaluate[] one of the >> Plot[] arguments. >> >> Good luck, >> Daniel >> > > Daniel; > > I tried your command above (You had a typo, 't2' should > be 't^2' or just 't'), any way, it does not work either. > > I am sure this is a bug in Mathematica, either the kernel or the > ControlSystems toolbox or the parser. > > It does not make sense for this command to work: > > Plot[ Evaluate[OutputResponse[sys, UnitStep[t], t]] , > {t, 0, 3}, PlotRange -> All] > > But if I now simply combine another function in the plot command, > so to plot 2 functions together, it will now fail: > > Plot[ {t^2, Evaluate[OutputResponse[sys, UnitStep[t], t]] }, > {t, 0, 3}, PlotRange -> All] > "plot::plnr: .... is not a machine-size real > > > Why would the second example above fail but the first not fail? > > btw, the output from the OutputResponse[] is simply a list that > contains a function of t, such as { Exp[t/2] Cos[t] } > > So, nothing too complicated here. > > bye, > Nasser > > > > Compare Plot[Evaluate@ {D[x, x]}, {x, 0, 1}] and Plot[{Evaluate@ D[x, x]}, {x, 0, 1}]. In the first case the evaluator looks at the first argument of Plot, sees the head Evaluate and evaluates the expression, obtaining {1}. In the second case the head of the expression is List, therefore the attribute HoldAll of Plot makes Mathematica skip the evaluation of the first argument. So the evaluator doesn't go inside the first argument, and Evaluate will be found only when x already has a numerical value assigned to it. Plot works like Block so we will have something similar to Block[{x = 0}, {Evaluate@ D[x, x]}]. The arguments of D are evaluated before looking for known definitions for D, again in full agreement with Mathematica's evaluation rules. The result is {D[0, 0]}, which is not a list of numbers. Maxim Rytin m.r at inbox.ru