科学计算科学计算 (21).pdf
《科学计算科学计算 (21).pdf》由会员分享,可在线阅读,更多相关《科学计算科学计算 (21).pdf(6页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、3.8 F3.8 Function unction Arguments Arguments and the and the S Scoop coop of of V VariableariableThe adjustability of function argumentsGlobal variables and local variablesnarginnargoutthe number of input argumentsthe number of output arguments1 1Adjustability of Function ArgumentAdjustability of F
2、unction Argumentfunction fout=test(a,b,c)if nargin=1fout=a;elseif nargin=2fout=a+b;elseif nargin=3fout=(a*b*c)/2;end fout=test(2)fout=2 fout=test(2,3,2)fout=6Create a function file test.m.Local variables:variables that are available only in specific process or functionsin the program.Global variable
3、s:variables that can be accessed and modified by any function.2 2Global Variables and Local VariablesGlobal Variables and Local VariablesDefine the form of global variables:global the name of variableCreate a function file wad.m.function f=wad(x,y)global ALPHA BETAf=ALPHA*x+BETA*y;Enter the command in the Command Window and get the output result.global ALPHA BETA ALPHA=1;BETA=2;s=wad(1,2)s=5
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 科学计算科学计算 21 科学 计算 21
限制150内