MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   资料存档 (https://www.labfans.com/bbs/forumdisplay.php?f=72)
-   -   在Matlab中最接近#define的东西是什么? (https://www.labfans.com/bbs/showthread.php?t=23156)

poster 2019-12-10 20:30

在Matlab中最接近#define的东西是什么?
 
在C语言中,我可能会执行以下操作:

#define MAGIC_NUMBER (88) int foo(int a, int b, int c) { return a + b + c + MAGIC_NUMBER; } double bar(double x, double n) { return x + n + MAGIC_NUMBER; } /* * ...and so on with many kind-of-long functions using * MAGIC_NUMBER instead of writing a literal 88 like so: */ double bar(double x, double n) { return x + n + 88; } 我应该在Matlab中做什么? (需要跨多个文件工作。)



[B]回答:[/B]

您可以定义一个[URL="http://www.mathworks.com/help/techdoc/ref/global.html"]全局变量[/URL]或声明一个仅返回常量值的函数(第二种可能性看起来更好)。



[url=https://stackoverflow.com/questions/2337934]更多&回答...[/url]


所有时间均为北京时间。现在的时间是 05:09

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.