function profiles = profiles_from_AFS1D(AFS,V,hx)
% computes the feasible profiles from an 1D-AFS for a two component system
% 
% input:
% AFS ...... area of feasible solutions computed by facpack
% V ........ matrix of the right singular vectors
% hx ....... stepsize for the discretization
% 
% example:
% profiles = profiles_from_AFS1D(AFS,V,0.1)

col = [0     0.4470     0.7410;
    0.8500    0.3250    0.0980;
    0.9290    0.6940    0.1250;
    0.4940    0.1840    0.5560;
    0.4660    0.6740    0.1880;
    0.3010    0.7450    0.9330];

for seg=1:2
    afs = AFS{seg};

    if seg == 1
        m = ceil((afs(2)-afs(1))/hx)+1;
    else
        m = ceil((afs(2)-afs(1))/hx)+1;
    end

    SolT = linspace(afs(1),afs(2),m)';
    profiles{seg} = [ones(m,1) SolT]*V(:,1:2)';
    
    figure(seg)
    plot(1:size(V,1), profiles{seg}, 'color', col(seg,:))
    axis tight
    yl = get(gca, 'ylim');
    set(gca, 'ylim',[min(0, yl(1)), yl(2)]);
end