Is it possible to use variables stored in the workspace inside another function ?
4 次查看(过去 30 天)
显示 更早的评论
Is it possible to use variables stored in the workspace inside another function?
3 个评论
Stephen23
2020-4-22
@HN: global variables and evalin are two anti-pattern options that you should definitely avoid using, unless you really want to force yourself into writing slow, compplex, obfuscated, buggy code that is difficult to debug.
The MATLAB documentation clearly states the the best practice is to pass input/output arguments:
采纳的回答
Star Strider
2020-4-22
The best option is to pass them to the function as extra parameters. See: Passing Extra Parameters for an extended discussion.
6 个评论
Star Strider
2020-4-23
Please see the documentation on Passing Extra Parameters that I linked to in my original post.
I have no idea what you are doing in your code (other than it appears to be a Runge-Kutta integrator).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!