function rop_fec = interp_fec_cross(rops, ber, fec_thr) if all(~isfinite(ber)) rop_fec = NaN; return; end idx = find(ber < fec_thr, 1, 'first'); if isempty(idx) || idx == 1 rop_fec = NaN; return; % no crossing end % linear interpolation between the two nearest points x1 = rops(idx-1); x2 = rops(idx); y1 = ber(idx-1); y2 = ber(idx); rop_fec = interp1([y1 y2], [x1 x2], fec_thr, 'linear', NaN); end