Local or global variables in programs?
Local or global variables in programs?
(OP)
Hi!
I wrote some big programs to describe the dynamical behavior of cars using matrices with submatrices, that means one entry of the matrix is another matrix (e.g. shown in the result as A=([3,1] [3,3] [12,4]). So far this way. I also take references to functions defined in other files using MathCAD 2001.
The mainprogram has NO inputvariables (all values are defined in the program itself), references subroutines and give back a matrix, including the actual position and velocity of the car in vectorial notation.
When I let calculate this program more then one time, the result changes from time to time (not only the values but also the dimension of the submatrices) even NO extern variable hast changed.
May it be, that matrices in programs are intern allocated by pointers (as I know from C++)? May it be, that the variables (especially matrices) aren't realy LOCAL (that means if yo change them in a procedure, a variable with the same name outside this procedure wouldn't be changed)? How can I inhibit this (recalculate the whole worksheet doesn't work)?
Here an example for swaping the order of vectors:
I know, this is a quite hard question, but has anybody an idea?
Christian M. (TU-Chemnitz, Germany)
I wrote some big programs to describe the dynamical behavior of cars using matrices with submatrices, that means one entry of the matrix is another matrix (e.g. shown in the result as A=([3,1] [3,3] [12,4]). So far this way. I also take references to functions defined in other files using MathCAD 2001.
The mainprogram has NO inputvariables (all values are defined in the program itself), references subroutines and give back a matrix, including the actual position and velocity of the car in vectorial notation.
When I let calculate this program more then one time, the result changes from time to time (not only the values but also the dimension of the submatrices) even NO extern variable hast changed.
May it be, that matrices in programs are intern allocated by pointers (as I know from C++)? May it be, that the variables (especially matrices) aren't realy LOCAL (that means if yo change them in a procedure, a variable with the same name outside this procedure wouldn't be changed)? How can I inhibit this (recalculate the whole worksheet doesn't work)?
Here an example for swaping the order of vectors:
I know, this is a quite hard question, but has anybody an idea?
Christian M. (TU-Chemnitz, Germany)
RE: Local or global variables in programs?
I am using Version 11.2a. Maybe a bug in Version 2001? Are there any service packs for Version 2001?
RE: Local or global variables in programs?
BUT then I can't mix submatrices with various dimensions (e.g. A={[3,1] [7,4] [2,9]}). Now I wrote all submatrices in one very big matrix {200,70} and it works quite well although the procedure looks terrible.
Maybe we will get the new MathCAD-12 version so service packs are no longer needed.
I just tried to mix submatrices with various dimensions in a little test program and it works! Hmmm, maybe the mistake in the main program is another one.
Thanks for helping,
Christian M. (TU-Chemnitz, Germany)
RE: Local or global variables in programs?
TTFN