avatar
about global in matlab# Computation - 科学计算
m*i
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?)
avatar
c*e
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?)

avatar
m*i
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.

avatar
a*a
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,

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。