Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.8K Views
|
6 Replies
|
6 Total Likes
View groups...
Share
Share this post:

Multiple expressions in a notebook Do loop

Posted 1 year ago

I'm doing a Do loop in my Mathematica notebook as I want to inspect plots associated with a list of files under dialog control. So near as I can tell the only way to have multiple expressions in a Mathematica looping structure is to separate them with semicolons. Unfortunately, putting a semicolon after a plot expression will not display the plot in the notebook. So, I assign all the plots to variables and terminate those lines in semicolons and then use the Column statement to present them all at once in a column. So, the Column statement has no semicolon, and although this whole limitation seems beyond stupid to me, at least I'll get my graphics presented with each loop iteration. However, I also want to present a dialog at the end of each loop iteration to halt the looping, inspect the plots and decide whether to make note of this case for more thorough analysis later. Well, that's another statement without a semicolon, else the dialog won't appear. Again, this single expression in a looping structure limitation seems beyond stupid to me. So, does anyone have any ideas how I do more than one non-semicolon expression in a Mathematica looping structure?

POSTED BY: Roger Backhus
6 Replies

No semicolons...?:

note = {}
Do[
 DialogInput[
  DialogNotebook[{
    ExpressionCell[Plot[Sin[n x], {x, 0, 2 Pi}], "Output"],
    TextCell["Wavy enough? "],
    Button["Save", DialogReturn[note = {note, n}]],
    DefaultButton["Skip", DialogReturn[]]
    }]
  ],
 {n, 10}]
Flatten@note
POSTED BY: Michael Rogers

To display a plot from a Do loop, simply wrap it in Print:

Do[Print[Plot[x^n, {x, -1, 1}]], {n, 4}]
POSTED BY: Gianluca Gorni

Do[], Scan[] are iterative structures that return no output (well, actually, each returns Null).

Table[], Map[] are iterative structures that return the values computed in each iteration. Perhaps one of them is what you're looking for.

POSTED BY: Michael Rogers
Posted 1 year ago
POSTED BY: Eric Rimbey
Posted 1 year ago

No code. Not worth the effort. English seems to work for most people. You don't understand "looping structure", "single expression", "semi colon", ... ?

POSTED BY: Roger Backhus

Welcome to Wolfram Community!
Please provide your efforts in the form of the Wolfram Language code. This will make it easier for other members to help you. Check several methods available to include your code in the rules http://wolfr.am/READ-1ST

POSTED BY: EDITORIAL BOARD
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard