Group Abstract Group Abstract

Message Boards Message Boards

0
|
12.5K Views
|
9 Replies
|
3 Total Likes
View groups...
Share
Share this post:

Errors when first opening Mathematica notebook

Posted 10 years ago

Hi there,

When I start up Mathematica and open a Notebook, I usually get a bunch of errors right off the bat. However, when I reevaluate the code (i.e., Shift + Enter), everything works just fine. What's going on? (Please see attached screenshots below.)

Many thanks!

On startup Error

After reevaluating Fixed

POSTED BY: Ilona
9 Replies

Nasser is incorrect in saying that code in initialization cells are executed on opening the notebook they are in. Upon (manual) evaluation of the first line of code Mathematica offers to evaluate initialization cells first. Only if you agree, and only then, is the initialization code evaluated.

A solution to your problem may be the use of the Manipulation option SaveDefinitions, but you should be aware of the dangers of using it.

POSTED BY: Sjoerd de Vries
Posted 10 years ago

Ahh okay. Thanks for your response! I guess I'll just stick with initializing within the Manipulate function.

POSTED BY: Ilona

You got the order wrong. If you put the Initialization :>... at the end, not first thing, it should work. The Manipulate pattern is this

  Manipulate[   somecode; somecode; morecode; Show[....], 
                        controlVariable,
                        controlVariable, 
                        Initialization :> (...)]

See if it works now.

POSTED BY: Nasser M. Abbasi
Posted 10 years ago

That solved the issue - thanks!

I'm just wondering, though, why it didn't work when I made points: = ... into an initialization cell (see image below). Do I have to ungroup it from all other cells? This didn't seem to work either.

enter image description here

POSTED BY: Ilona
POSTED BY: Nasser M. Abbasi
Posted 10 years ago
POSTED BY: Ilona

It happens if Dynamic Content for the notebook is enabled, so Manipulate starts working on load to present a picture, but

points1 = Table[<snip>, {i,70},{j,70}]

remains unevaluated, as the error message says. It can be fixed be putting

points1 = Table[<snip>, {i,70},{j,70}]

into a separate Initialization cell or by disabling Dynamic Content, of course.

POSTED BY: Udo Krause
Posted 10 years ago

Thanks so much! That really helps. (I didn't know about separating cells.)

POSTED BY: Ilona
Posted 10 years ago

I tried separating the cells, but I'm still getting errors when first opening the notebook. What did I do wrong? (See image below.)

enter image description here

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