This is the correct way to do such a thing
f = @(x, a, b) fun(x, a, b);
opt = @(a, b, x1, x2) fminbnd(@(x) f(x, a, b), x1, x2);
[Xopt, Fopt] = arrayfun(opt, A, B, X1, X2);
or
f = @(x, a, b) fun(x, a, b);
opt = @(a, b, x1, x2) fminbnd(@(x) f(x, a, b), x1, x2);
[Xopt, Fopt] = arrayfun(@(a, b, x1, x2) opt(a, b, x1, x2), A, B, X1, X2);
The first one is more readable.
0 Comments
Sign in to comment.