| [iflag,m,n,x,fvec,fjrow,nrow]=fcn3(iflag,m,n,x,fvec,fjrow,nrow); |
function [iflag,m,n,x,fvec,fjrow,nrow]=fcn3(iflag,m,n,x,fvec,fjrow,nrow);
persistent firstCall i temp two ; if isempty(firstCall),firstCall=1;end;
fjrow_shape=size(fjrow);fjrow=reshape(fjrow,1,[]);
fvec_shape=size(fvec);fvec=reshape(fvec,1,[]);
x_shape=size(x);x=reshape(x,1,[]);
if isempty(temp), temp=0; end;
if isempty(two), two=0; end;
if isempty(i), i=0; end;
if firstCall, two=[2.0e0]; end;
firstCall=0;
if( iflag==0 )
fjrow_shape=zeros(fjrow_shape);fjrow_shape(:)=fjrow(1:numel(fjrow_shape));fjrow=fjrow_shape;
fvec_shape=zeros(fvec_shape);fvec_shape(:)=fvec(1:numel(fvec_shape));fvec=fvec_shape;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
return;
end;
if( iflag==1 )
for i = 1 : m;
temp = i;
fvec(i) = two + two.*temp - exp(temp.*x(1)) - exp(temp.*x(2));
end; i = fix(m+1);
else;
if( iflag~=3 )
fjrow_shape=zeros(fjrow_shape);fjrow_shape(:)=fjrow(1:numel(fjrow_shape));fjrow=fjrow_shape;
fvec_shape=zeros(fvec_shape);fvec_shape(:)=fvec(1:numel(fvec_shape));fvec=fvec_shape;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
return;
end;
temp = nrow;
fjrow(1) = -temp.*exp(temp.*x(1));
fjrow(2) = -temp.*exp(temp.*x(2));
end;
fjrow_shape=zeros(fjrow_shape);fjrow_shape(:)=fjrow(1:numel(fjrow_shape));fjrow=fjrow_shape;
fvec_shape=zeros(fvec_shape);fvec_shape(:)=fvec(1:numel(fvec_shape));fvec=fvec_shape;
x_shape=zeros(x_shape);x_shape(:)=x(1:numel(x_shape));x=x_shape;
end %subroutine fcn3
|
|