%% current = 225:10:285; current = string(current); power = [28.02, 33.2, 37.5, 42.3, 46.3, 49.3, 53.4]; power = string(power); num_pf_coeff = 4; taps_ffe = [300, 0, 0]; taps_dfe = [2, 0, 0]; M = 4; trlength = 4096*4; x = 225:10:285; BER_PAM_4 = []; filter_length = 210; eq_method = 2; num_signal_sweep = 11; our_signal = 1; idx = 4; obj = @(x) first_analysis_ber( ... current(idx), power(idx), num_pf_coeff, taps_ffe, taps_dfe, ... M, trlength, eq_method, filter_length, num_signal_sweep, our_signal, x); x0 = [1 0.1 0.1]; lb = [1 0 0]; ub = [10 1 1]; opts = optimoptions('fmincon', ... 'Display','iter', ... 'Algorithm','sqp', ... 'MaxFunctionEvaluations', 500, ... 'StepTolerance', 1e-3, ... 'OptimalityTolerance', 1e-3); [xbest, berbest] = fmincon(obj, x0, [], [], [], [], lb, ub, [], opts);