Hello, i need to solve this with optimization toolbox.
My first attempt was this code but this is not optimization toolbox.
clearvars; clc; clear; close all;
fprintf('Minimum harmonies should be selected is %d for contain %s of the modulated signal power.\n',n,'%99');
fprintf('Also, with this harmonies we can contain up to %s%.2f of the modulated signal power.\n','%',nopt*2);
B = symsum((besselj(k,5)).^2,k,1,x);
And i tried with fmincon but i have some errors.
clearvars; clc; clear; close all;
options = optimoptions("fmincon",...
"Algorithm","interior-point",...
"EnableFeasibilityMode",true,...
"SubproblemAlgorithm","cg");
s = fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options);
B = symsum((besselj(k,5)).^2,k,1,x);
function [c,ceq] = confun(x)
with these errors:
Operator '-' is not supported for operands of type 'function_handle'.
Error in hw2v2>confun (line 24)
Error in fmincon (line 655)
[ctmp,ceqtmp] = feval(confcn{3},X,varargin{:});
s = fmincon(@objfun,x0,[],[],[],[],[],[],@confun,options);
Thanks in advance.