Message Boards Message Boards

3 Replies
0 Total Likes
View groups...
Share this post:

Variables not global

Posted 10 years ago

My notebook alternates between variables, text, and image input. When I call the previously defined variables in an operation, they are no longer remembered.

Is there a method for keeping the variables global so they can be recalled later in the notebook?

First day trying out Mathematica. I'm confident that it's extraordinary so I hope to have success with the software.


POSTED BY: Mike Abell
3 Replies

Ah, you figured it out as I was writing my reply! Enjoy!

POSTED BY: David Reiss

In a given Mathematica session all variables that you set are remembered throughout the session unless you explicitly clear them or unless they were localized using, for example, Module or Block. If you quit Mathematica and then reopen the notebook the variables are not remembered from the previous session (except in the special cases where they were saved in certain user interface constructs--a more advance issue though which you will not encounter until later in your process of learning Mathematica).

So if you execute


then any time later in the Mathematica session where you use x, it will have the value 5.

If though, the Mathematica Kernel crashes for some reason (shouldn't happen, but it sometimes does), then you will be effectively be starting a new Mathematica session and the value of x will not be known in the new session unless you set it to 5 once again.

So this leads me to believe that what you are describing is something other than how it reads. Could you give a simple example of what you are describing?

POSTED BY: David Reiss

I got it now, looks like the variables need to be entered as you go through the notebook.


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

Group Abstract Group Abstract