Hello world!
I'm facing some issues in finding the minimum of a function that comes from the sum of anonymous functions. I feel it's a silly thing, most probably in the anonymous function creation with which I still need some practice.
Real code is starting from data collected from measurements: for the sake of simpllicity I've just inserted a generic array.
d = 0:10:1000; n = length(d)xg_w = [200 1]; % Initial guess
RO = 800; % run-outs
e = @exp;L_W_temp = cell(n,1);z1 = @(par) (log(RO)-log(par(1)))*par(2);MLW = @(par) 0;for i = 1:n if d(i)>=RO L_W_temp{i} = @(par) -e(z1(par(1),par(2))); else z2 = @(par) (log(d(i))-log(par(1)))*par(2); L_W_temp{i} = @(par) log(par(2))-e(z2(par))+z2(par)-log(d(i)); endMLW = @(par) MLW(par)-L_W_temp{i}(par);endx_weib = fminsearch(MLW,xg_w);
I needed to create function "e" since it returned me errors when I tried to use "exp(z1(par(1),par(2)))".
Anyway, main problem is with fminsearch function, which shows me the error:
Error using springsL3>@(par)(log(RO)-log(par(1)))*par(2)Too many input arguments.Error in springsL3>@(par)-e(z1(par(1),par(2)))Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in springsL3>@(par)MLW(par)-L_W_temp{i}(par)Error in fminsearch (line 189)fv(:,1) = funfcn(x,varargin{:});Error in springsL3 (line 46)x_weib = fminsearch(MLW,xg_w);
where "springsL3" is the name of the script in my pc.
Thank you for your help,
Riccardo
Best Answer