Error in fminsearch (line 200) fv(:,1) = funfcn(x,varargin{:});
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tushar Verma
el 12 de Nov. de 2020
Respondida: Ameer Hamza
el 12 de Nov. de 2020
I'm trying to get an optimised curve fir for my data, but i get the error
fun = @(x)(x(1).*(A).^2 + x(2).*(B).^2 + x(3).*(C).^2 + x(4).*(D).^2 -(E).^2);
x0 = zeros(1,4);
param = fminsearch(fun,x0);
2 comentarios
Respuesta aceptada
Ameer Hamza
el 12 de Nov. de 2020
Objective function must return a scalar value, whereas, in your case, it returns a 576x1 vector. Following code uses norm() to take l2-norm of 576x1 to return a scalar.
A = rand(576,1); % example values
B = rand(576,1);
C = rand(576,1);
D = rand(576,1);
E = rand(576,1);
fun = @(x) norm((x(1).*(A).^2 + x(2).*(B).^2 + x(3).*(C).^2 + x(4).*(D).^2 -(E).^2));
x0 = zeros(1,4);
param = fminsearch(fun,x0);
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Digital Filter Design en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!