# The problem encounterend while calling a sub notebook from the main notebook

I have two notebooks; one of them is the main notebook which will call the second notebook several times in a loop and inside this loop, matrix called as ALLB, defined in the main notebook, will get the results of the sub notebook's matrix LB[[1,t]].

The problem is matrix ALLB contains the results of the last sub notebook evaluation. For example I have a loop inside the main notebook calculating two times

  For[ni = 4, ni < 6, ni++,

i = ni - 1;

nbLB = NotebookOpen[ToFileName[docpath, "Local_B_spline_Basis.nb"]];

SelectionMove[nbLB, All, Notebook];

SelectionEvaluate[nbLB];

For[t = 1, t < p + 2, t++,

ALLB[[ni, t]] = LB[[1, t]];

];
NotebookClose[nbLB];
];


I find that ALLB[[4,:]]=ALLB[[5,:]] but they must be different. Because in the begining of the loop, my variable "i" changes and then by calling the subnotebook here named as nbLB, its calculations are dependent on the variable i and it must return different LB[[1,t]] matrices and then assigning this different matrices to the ALLB matrix ; ALLB[[4,:]] =! ALLB[[5,:]] I have to find them different but I unfortunately find them exactly the same.

Where do I make a mistake, please help ?

Best Regards;

Dr. Ahmet Hasim

• What is the value of p? What do you mean by e.g. [[4, :]] in your code examples? – MarcoB Jun 21 '16 at 13:24
• Hi MarcoB; p is just a variable defined before lets say p = 2. [[4, :]] means I find all the columns for the fourth row of the matrix ALLB is equal to the fifth row. But they must be different. – ahmethasim Jun 21 '16 at 13:34