3
$\begingroup$

Basically I have a notebook (let's call it nb1) that when evaluated yields one number when I specify some parameter $\alpha$ (in nb1). I want to call nb1 in a different notebook (nb2) using for instance the NotebookEvaluate function, such that I can use the value calculated in nb1 in my second notebook nb2. Is there a neat way to do this, that also allows me to evaluate nb1 for different values of $\alpha$?

For concreteness I would like to do something like this in nb2:

tab = Table[NotebookEvaluate[nb1],{alpha,1,1000}];

My question is: What do I have to write in nb1 to run the table command as above?

I hope the above pseudocode illustrates what I want to do clearly.

I do not want to convert nb1 to a function, because the notebook is so long that I'm bound to run into a bunch of unforseen errors.

$\endgroup$
3
  • $\begingroup$ do not use N as a parameter, this is a function N[expr] gives the numerical value of expr. if you evaluated nb1 and then nb2, all data from nb1 is available in nb2. $\endgroup$ Jan 22, 2019 at 20:45
  • 1
    $\begingroup$ Is there something specific I must write in nb1 to store the values in nb2? At the moment i've written s =NotebookEvaluate[ directory" <> "QuantumScattering.nb", InsertResults -> True]; in nb2 but s does not contain the outputs of nb1 $\endgroup$
    – MOOSE
    Jan 23, 2019 at 11:09
  • 1
    $\begingroup$ It is possible that in nb2 there are commands like ClearAll[f] ,Clear[f] for the parameter f being used. $\endgroup$ Jan 23, 2019 at 11:53

1 Answer 1

1
$\begingroup$

When you run the following in NB2,

Get["file directory path//file name of NB1"]

All the definitions calculated in NB1 will be available within NB2. Then you can do the calculations in NB2.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.