Error in fminsearch (line 200) fv(:,1) = funfcn(x,varargin{:});
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tushar Verma
am 12 Nov. 2020
Beantwortet: Ameer Hamza
am 12 Nov. 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 Kommentare
Akzeptierte Antwort
Ameer Hamza
am 12 Nov. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Digital Filter Design finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!