MATLAB中函数模式和命令模式的区别
2012-11-05 14:51
1136 查看
FUNCTION FORMAT
A command in this format consists of the function name followed by
one or more arguments separated by commas and enclosed in parentheses
函数格式的命令由函数名和紧随其后的一个或者多个参数组成;这些参数用,隔开
并放在()里面。
.
functionname(arg1, arg2, ..., argn)
You may assign the output of the function to one or more output values
separated by commas and enclosed in square brackets ([]).
你也可以指定函数的输出为一个或者多个输出变量,用,隔开
并放在()里面。
[out1, out2, ..., outn] = functionname(arg1, arg2, ..., argn)
For example,
copyfile(srcfile, '..\mytests', 'writable')
[x1, x2, x3, x4] = deal(A{:})
Arguments are passed to the function by value. See the examples below,
under ARGUMENT PASSING. 参数是被传送到函数的值
COMMAND FORMAT
A command in this format consists of the function name followed by
one or more arguments separated by spaces.
命令模式命令由函数名和紧随其后的一个或者多个参数组成,这些参数用空格隔开。
functionname arg1 arg2 ... argn
Unlike the function format, you may not assign the output of the function
to a variable. Attempting to do so generates an error.
有别于函数模式,你不能把函数的输出指向变量。如果这样做会产生错误。
For example
save mydata.mat x y z
import java.awt.Button java.lang.String
Arguments are treated as string literals. See the examples below,
under ARGUMENT PASSING.
这里的参数被当成字符串常量。
ARGUMENT PASSING
In the FUNCTION format, arguments are passed by value.
在函数模式,参数被变量传递。
In the COMMAND format, arguments are treated as string literals.
在命令模式,参数被当做字符串常量。
In the following example,
disp(A) - passes the value of variable A to the disp function
disp A - passes the variable name, 'A'
A = pi;
disp(A) % Function format
3.1416
disp A % Command format
A
In the next example,
strcmp(str1, str2) - compares the strings 'one' and 'one'
strcmp str1 str2 - compares the strings 'str1' and 'str2'
str1 = 'one'; str2 = 'one';
strcmp(str1, str2) % Function format
ans =
1 (equal)
strcmp str1 str2 % Command format
ans =
0 (unequal)
A command in this format consists of the function name followed by
one or more arguments separated by commas and enclosed in parentheses
函数格式的命令由函数名和紧随其后的一个或者多个参数组成;这些参数用,隔开
并放在()里面。
.
functionname(arg1, arg2, ..., argn)
You may assign the output of the function to one or more output values
separated by commas and enclosed in square brackets ([]).
你也可以指定函数的输出为一个或者多个输出变量,用,隔开
并放在()里面。
[out1, out2, ..., outn] = functionname(arg1, arg2, ..., argn)
For example,
copyfile(srcfile, '..\mytests', 'writable')
[x1, x2, x3, x4] = deal(A{:})
Arguments are passed to the function by value. See the examples below,
under ARGUMENT PASSING. 参数是被传送到函数的值
COMMAND FORMAT
A command in this format consists of the function name followed by
one or more arguments separated by spaces.
命令模式命令由函数名和紧随其后的一个或者多个参数组成,这些参数用空格隔开。
functionname arg1 arg2 ... argn
Unlike the function format, you may not assign the output of the function
to a variable. Attempting to do so generates an error.
有别于函数模式,你不能把函数的输出指向变量。如果这样做会产生错误。
For example
save mydata.mat x y z
import java.awt.Button java.lang.String
Arguments are treated as string literals. See the examples below,
under ARGUMENT PASSING.
这里的参数被当成字符串常量。
ARGUMENT PASSING
In the FUNCTION format, arguments are passed by value.
在函数模式,参数被变量传递。
In the COMMAND format, arguments are treated as string literals.
在命令模式,参数被当做字符串常量。
In the following example,
disp(A) - passes the value of variable A to the disp function
disp A - passes the variable name, 'A'
A = pi;
disp(A) % Function format
3.1416
disp A % Command format
A
In the next example,
strcmp(str1, str2) - compares the strings 'one' and 'one'
strcmp str1 str2 - compares the strings 'str1' and 'str2'
str1 = 'one'; str2 = 'one';
strcmp(str1, str2) % Function format
ans =
1 (equal)
strcmp str1 str2 % Command format
ans =
0 (unequal)
相关文章推荐
- lazarus中不同模式下自定义函数的调用方式区别
- Matlab 图像处理相关函数命令大全
- 讨论Matlab中double,im2double,mat2gray函数区别
- Matlab中常用的一些命令和函数的小结
- 把Matlab里求相关函数的xcorr命令彻底搞清楚
- matlab常用命令和常用函数(有重复)
- MATLAB函数及命令全集-(按字母排序)
- php调用外部命令函数system,exec,passthru的区别和用法详解
- MATLAB的cd函数与cd命令
- RGB转到LAB颜色空间,matlab和opencv内嵌函数使用的区别
- 个人理解--代理模式和命令模式区别
- 3.2 内核模式下各种开头函数的区别
- Matlab显示图像时函数imge和imshow的区别
- Matlab 图像处理相关函数命令大全
- matlab 命令 conv2与filter的区别
- Python3 执行操作系统命令的函数 system 和 popen 的区别
- matlab 入门基本操作命令与函数
- Matlab 图像处理相关函数命令大全
- rand, randn和randint函数的区别(MATLAB)
- 把Matlab里求相关函数的xcorr命令彻底搞清楚