Matlab函数参数问题

时间:2014-02-08 22:06:53

标签: matlab function iteration

嘿我有一个定义为

的函数
drift = @(x1,x2,u)[x2,(a*sin(x1) - b*x2 + u)]*.05;

然后我尝试在三重for循环中调用它(迭代

  • x1 = 1:长度(n1),

  • x2 = 1:长度(n2)

  • x3 = 1:长度(nu)

next = [n1(x1), n2(x2)] + drift([n1(x1), n2(x2), nu(k)]);

我使用myMDP获取错误> @(x1,x2,u)[x2,(a * sin(x1)-b * x2 + u)] *。05(第148行) 没有足够的输入参数。

那个错误。为什么呢?

1 个答案:

答案 0 :(得分:0)

f([1,2,3]) %function call with a single parameter, which is a 3 element vector
f(1,2,3) %function call with three parameters
f([1,2,3],[1,2,3],[1,2,3]) %function call with three parameters, each a 3 element vector.