Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #7494 > unrolled thread
| Started by | Murray Eisenberg <murray@math.umass.edu> |
|---|---|
| First post | 2011-12-31 07:01 +0000 |
| Last post | 2011-12-31 07:01 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Plot in a Module Murray Eisenberg <murray@math.umass.edu> - 2011-12-31 07:01 +0000
| From | Murray Eisenberg <murray@math.umass.edu> |
|---|---|
| Date | 2011-12-31 07:01 +0000 |
| Subject | Re: Plot in a Module |
| Message-ID | <jdmc0f$gs4$1@smc.vnet.net> |
I don't quite understand your question. There's nothing "illegal" or
improper about omitting a semicolon after a Plot expression within a
Module. For example,
Module[{c}, c = 2; Print[Plot[c x, {x, 0, 1}]]]
is perfectly legal.
Perhaps your question is about a Module whose body has additional parts
of the compound expression after the Plot part, e.g."
Module[{c}, c = 2; Plot[c x, {x, 0, 1}]; c + 2]
In this case, the red-highlighted semicolon that you'll see after the
Plot expression is not an indicator of any syntactical error -- not
"illegal" -- but a warning that you may not be getting what you expect,
namely, that the Plot expression's output will be suppressed. (Just like
if you simply typed a Plot expression alone, without any enclosing
Module, and terminated it with a semicolon.)
So what you want would be something like:
Module[{c}, c = 2; Print[Plot[c x, {x, 0, 1}]]; 2 + 3]
The Print wrapping the Plot forces the Plot output to be shown.
Hope this helps.
On 12/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
>
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web