Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #7461

Re: Plot in a Module

From W Craig Carter <ccarter@mit.edu>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Plot in a Module
Date 2011-12-29 07:50 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jdh63n$khk$1@smc.vnet.net> (permalink)
References <201112281016.FAA08942@smc.vnet.net>

Show all headers | View raw


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
> 

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Plot in a Module W Craig Carter <ccarter@mit.edu> - 2011-12-29 07:50 +0000

csiph-web