function y=myfunction(a,b)
其中a,b是输入函数的参数,y是函数返回的值。当需要返回多个值时,可以将y看作一个数组,或者直接将函数的开头写成如function [x,y]=myfunction(x,y)的形式。
然后就是定义函数的内容,通俗的说就是怎样由输入参数a,b得到返回值y。比如最简单的y=a+b。
总结一下,将下面的代码
function y=myfunction(a,b)
y=a+b
保存为一个m文件myfunction.m,调用方式如下。
num=myfunction(3,4)
这样就可以由函数中的y=a+b得到num的值是3+4=7。
以上是最简单的例子,不知说清楚没有,
相当于一个函数,你可以看下:x <- rnorm(1000)
y <- ecdf(x)
y(x)
plot(x,y(x), ylab = "ECDF(x)")
关于r语言中find函数的用法:find(matlab)
find()所属R语言包:matlab
描述----------Description----------
Finds indices of elements.
查找的元素的索引。
用法----------Usage----------
find(x)
参数----------Arguments----------
参数:x
expression to evaluate
要计算的表达式
Details
If expression is not logical, finds indices of nonzero elements of argument x.
如果是不符合逻辑的表达,发现指数的非零元素的参数x。
值----------Value----------
Returns indices of corresponding elements matching the expression x.
返回指数的相应匹配的元素的表达x。
P. Roebuck <a href="mailto:[email protected]"[email protected]</a>
实例
----------Examples----------
find(-3:3 >= 0)
find(c(0, 1, 0, 2, 3))