function [b,x] = inconvhull(q,P) % is q in the convex hull generated by the col. vectors P? % try my own thing [n, T] = size(P); f = ones(1,T); LB = zeros(T,1); x = linprog(f,[],[],P,q,LB,[]); b = ~isempty(x); if b b = totdif(P*x,q) < 1e-9; end return % this thing doesn't work, maybe figure out why later... %function [b,fval,x] = inconvhull(q,P) [n, T] = size(P); q = [q;-1]; P = [P;-ones(1,T)]; Ain = [P'; q'] Bin = [zeros(T,1); 1] [x,fval] = linprog(-q,Ain,Bin); %b = (fval>=1e-15); b = (fval>=0); return