Re: Plot in a Module
- To: mathgroup at smc.vnet.net
- Subject: [mg123891] Re: Plot in a Module
- From: W Craig Carter <ccarter at mit.edu>
- Date: Thu, 29 Dec 2011 02:49:41 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201112281016.FAA08942@smc.vnet.net>
Hello Sam,
Here is an example
example[f_, g_, {lower_, upper_}] :=
Module[{integral, dum, plotIntermediate},
integral[x_] = Integrate[f[dum] g[dum], {x, lower, upper}];
plotIntermediate =
Plot[integral[dum], {dum, lower, upper}, PlotStyle -> {Red, Thick}];
Show[plotIntermediate, Plot[f[dum] g[dum], {dum, lower, upper}]]
]
example[Sin, Cos, {0, 2 Pi}]
Module isn't necessary in the example, but it serves to demonstrate usage.
W Craig Carter
Professor of Materials Science, MIT
On Dec 28, 2011, at Wed, Dec 28, 11 ---5:16 AM, Sam Takoy wrote:
> Hi,
>
> How does one use the Plot command inside a Module? I find that if one
> places a semi-colon after the command, then the output is suppressed.
> But it also seems illegal to skip the semi-colon? So how does one do
> it?
>
> Many thanks in advance,
>
> Sam
>
- References:
- Plot in a Module
- From: Sam Takoy <sam.takoy@yahoo.com>
- Plot in a Module