Message Boards Message Boards

Calling a huge parameter from a different notebook?

I have a huge notebook with several pages. I have set parameters in the beginning of the notebook and I want to see a picture near the end of the notebook in such a way that when I want to change one parameter I must go from the beginning to the end. Is there a way to put the parameter in an other notebook and stay at the level of my picture ? In short, to command a notebook from an other ?

POSTED BY: Cyrille Piatecki
5 Replies

If you want to send me your notebook, or the simplest version of it - and it has all the necessary initializations so it will evaluate - maybe I can give some more explicit suggestions. My email is in my profile.

Your work might easily develop into an application - something more than just scratchpad calculations. I have an essay on my web site "A Mathematica Style" that gives information on how to organize your work this way, including using packages.

A Mathematica Style

The reason I mentioned a Module is that a Module can use temporary variables and have many statements within it. It could check parameters and issue error messages if they are not valid. If they are valid it could establish definitions for other routines you might use. All of these statements would be within the Module and not scattered through the notebook. You could have a Routines section at the top of your notebook that contained the Module routine (and other routines). Once the routine was tested you could close the Routines section so it wouldn't take a lot of space in the notebook.

Thanks David for your answer. I will try your solution but for what I am doing It does not give a simple answer.

I have a lot of functions depending of a vector of parameters and of a variable. Some of those function are conditions which must be verified. So I am obliged to make a test or more simple to plot them.

Other function are combined like u:=f(y(x); z(x)). But those are 2 or 3 pages after the first definition. If I change the value of a parameter, I need to go at the top of the nb reevaluate all then go to see the result at the end of the 3 pages. I was wondering if I could set the parameter in one notebook and with the help of an special command run my principal notebook which stay at the place of my main graphic.

POSTED BY: Cyrille Piatecki

I guess my first question would be: How much experience have you had with Mathematica? Have you ever written routine definitions or specifications? Have you ever used a Module or With statement? Have you ever written a usage statement or a statement that generates a Message?

Could you write a routine that checks the validity of your set of parameters? If they are not valid it might print error messages and Abort the calculation. If they are a valid set then you could complete the calculation and make a plot, although the plot would probably be another separate routine. Or maybe if the parameters are valid then the routine would establish a number of function definitions that are based on those parameters. Then further calculations would use those definition.

The object then is to partition your calculation into a number of steps, which themselves are encapsulated in routines, usually using a Module. Parameters and variables should be arguments in functions and not things that are set by separate statements in the notebook.

Dear David,

sorry to have been late to follow up the discussion.

Obviously I am a newcomer in the programmation side of mathematica. For twenty years, I used it only to verify if what I have found with pencil and paper was right. I want now to use it in a better way. The problem is that it is very difficult to follow what some high programming spirit have decided to program. For instance, some weeks ago, I decide to use mathematica in batch mode under windows 7 or 8. It was impossible to follow the documentation because nothing was working. At the end, I have asked a question in this list to discover that Mathematica should be called as any dos programming. May be it was obvious for some, but is there no warning in the documentation. It happen exactly the qame thing with the problem I have encounter today, but this time on Mac.

After your nice suggestion I used in the past one time to make a recursion, I have finally understood that I must make a m file and call it from a notebook to solve my problem. On my computer all was ok. But I work with a MAC collegue. And under MAC, the process to set the directory were was the m and the nb file is not the same as under windows. But it was very difficult to find the good tuto.

Mathematica is a wonderfull object but it is some time difficult to learn. Thanks for your interest in my problem

Cyrille

POSTED BY: Cyrille Piatecki

Cyrille, your question is a bit vague and so I don't have a good picture of what you are doing. I have a picture of you calculating something step by step with various steps in different cells and then using the result to make a plot.

If so, then one solution is to consider your work as a preliminary exploration and then trying to write a routine where the parameter you define near the top of the notebook would be a parameter in the routine definition. Then at the time you make your plot you can specify the value of the parameter, rather than specifying it at the top of the notebook.

Here is a simpler example. Suppose an ellipse with semi-axes a and b was part of your plot. Then at the top of your notebook you could define a parameterization for the ellipse. (Taken from Alfred Gray, Modern Differential Geometry)

ellipse[a_,b_][t_]:= {a Cos[t], b Sin[t]}

where a and b are the parameters in the definition. You only need to specify their values at the time you make the plot.

For a more complicated object the right hand side would probably be a Module with various steps and intermediate results.

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

Group Abstract Group Abstract