m**i 发帖数: 724 | 1 I use the profile commands to track my program, to my surprise I found that
the
line that "global a b c" takes a lot of time.
My a b c are cell arries. Is that the reason? Are there other ways that I can
share some variables among functions (Basically, I just want to initilize a,
b, c at the very beginning of the simulation, and use them later. Will
save/load be better?) | c*******e 发帖数: 8624 | 2 You can load these variables at the beginning of each program if necessary.
Just write it as a separate function to put all the constansts.
【在 m**i 的大作中提到】 : I use the profile commands to track my program, to my surprise I found that : the : line that "global a b c" takes a lot of time. : My a b c are cell arries. Is that the reason? Are there other ways that I can : share some variables among functions (Basically, I just want to initilize a, : b, c at the very beginning of the simulation, and use them later. Will : save/load be better?)
| m**i 发帖数: 724 | 3 I found I can only load the variables into the base workspace. But I want use
them in a function (which has its own workspace.)
that
can
a,
【在 c*******e 的大作中提到】 : You can load these variables at the beginning of each program if necessary. : Just write it as a separate function to put all the constansts.
| a**a 发帖数: 63 | 4 It's not a good thing to use global variables. You can always wrap these
"global variables" into a structure, and pass it through different functions
use
necessary.
I
initilize
【在 m**i 的大作中提到】 : I found I can only load the variables into the base workspace. But I want use : them in a function (which has its own workspace.) : : that : can : a,
|
|