我收到错误"没有足够的输入参数"当使用另外两个参数调用作为参数传递的函数时。
>>q = [.33 .423 .523 1.023 .6 1.047]';
>>NewtRaphDynamics(q,0,PA1_PHI,PA1_Jacobian)
Error using PA1_PHI (line 8)
Not enough input arguments.
其中PA1_PHI和PA1_Jacobian是matlab目录中的函数文件。因此NewtRaphDynamics函数是:
function [qout D] = NewtRaphDynamics(iq,t,PHI,Jac,err,it)
%... code setting defaults for 'err' and 'it' if they are not specified ...
norm = @(what) sqrt(what'*what);
iter = 0;
iq
pause
% Solving for position problem q
while iter < it
iPHI = PHI(iq,t);
D = Jac(iq);
if(norm(iPHI) < err), break, end
deliq = - D\iPHI;
iq = iq + deliq;
iter = iter + 1;
end
qout = [t iq'];
抛出错误的函数调用是:
function PHI = PA1_PHI(q,t)
PHI = zeros(6,1);
PHI(1) = q(1) - .5*cos(q(3)) + .2*sin(q(3));
PHI(2) = q(2) - .5*sin(q(3)) - .2*cos(q(3));
PHI(3) = q(4) - .4*cos(q(6)) - (q(1) + .7*cos(q(3)) + .1*sin(q(3)));
PHI(4) = q(5) - .4*sin(q(6)) - (q(2) + .7*sin(q(3)) - .1*cos(q(3)));
PHI(5) = q(4) + .4*cos(q(6)) - 1.6;
PHI(6) = q(5) + .4*sin(q(6)) - (1 - .2*cos(2*pi*t)); % appended constraint