clear; close all; x1 = -4:0.1:4; x2 = -4:0.1:4; f1 = 1-exp(-(x1-1/sqrt(2)).^2-(x2-1/sqrt(2)).^2); f2 = 1-exp(-(x1+1/sqrt(2)).^2-(x2+1/sqrt(2)).^2); plot(f1,f2,'rx'); hold on; w1s = 0:0.1:1.0; w2s = 0:0.1:1.0; x1opts = []; x2opts = []; for i=1:length(w1s) w1 = w1s(i); for j=1:length(w2s) w2 = w2s(j); C = w1*f1+w2*f2; if length(find(C==min(C)))>2 continue end x1opt = x1(find(C==min(C),1)); x2opt = x2(find(C==min(C),1)); x1opts(end+1)=x1opt; x2opts(end+1)=x1opt; end end x1opts = unique(sort(x1opts)) x2opts = unique(sort(x2opts)) f1opts = 1-exp(-(x1opts-1/sqrt(2)).^2-(x2opts-1/sqrt(2)).^2); f2opts = 1-exp(-(x1opts+1/sqrt(2)).^2-(x2opts+1/sqrt(2)).^2); plot(f1opts,f2opts,'bo'); big;