function [TheEndmembers,EndMemberValues,SolidSolution] = CreateEndMembers(additives,themineral,...
MineralStruct)
%[TheEndmembers,EndMemberValues,SolidSolution] = CreateEndMembers(additives,themineral,MineralCell)
%This program takes additive/exchange components and converts to endmembers
%INPUT
%additives = the values of the additive/exchange components for this mineral
%themineral = The mineral that is currently being considered
%MineralStruct = The output of CreateMineralCell.m which contains alot of background information
%
%OUPUT
%TheEndmembers = The cell array that contains the names of the endmembers
%EndMemberValues = The values of these endmembers
%SolidSolution = Is the phase a solid solution 
%
%Written by K. Steffen (ksteffen@unm.edu) at the University of New Mexico,
%Department of Earch and Planetary Science
%Copyright 2003 Kurt Steffen
%
%Last Modified June 17, 2003
    for k = 1:length(MineralStruct)
        theminerallist(k) = MineralStruct(k).MineralName;
    end
    thecolumn = GetColumnsGeneral(theminerallist,themineral);
    thecolumn = thecolumn{2,1};
    TheEndmembers = MineralStruct(thecolumn).EndMembers;
    Conversion = MineralStruct(thecolumn).Conversion;
    if length(Conversion) == 1
        SolidSolution = 0;
    else
        SolidSolution = 1;
    end
    Base = MineralStruct(thecolumn).Endbase;
    
    if SolidSolution
        EndMemberValues = Base + additives'*Conversion;
    else
        EndMemberValues = Base;
    end