function buttonsaveCAA(hObject, eventdata, Empty_Button)
data = get(Empty_Button,'UserData');

supersetAFSA = data.AFSA;
supersetAFSC = data.AFSC;

x = data.x;
t = data.t;
D = data.D;

U = data.U;
S = data.S;
V = data.V;

T = [];
A = [];
C = [];

if sum(data.choosen) == 3
    T = [ones(3,1) data.fixA];
    A = T*data.V';
    A = diag(1./max(abs(A')))*A;
    C = data.U*data.S*pinv(T);
    C = C*diag(1./max(abs(C)));
end

for i=1:3
    if data.choosen(i) == 1
        T(i,:) = [1, data.fixA(i,:)];
        A(i,:) = T(i,:)*data.V';
        A(i,:) = A(i,:)/max(abs(A(i,:)));
    end
    if data.choosenC(i) == 1
        pt = [1; data.fixC(i,:)'];
        C(:,i) = data.U*data.S*pt;
        C(:,i) = C(:,i)/max(abs(C(:,i)));
    end
end

if (isfield(data,'full') == 1) && (isfield(data.full,'isC')*isfield(data.full,'isA') == 1) && (data.full.isC*data.full.isA == 1)
    fullAFSC = data.full.AFSC;
    fullAFSA = data.full.AFSA;
    if (isfield(data,'isAFSA') == 1) && (isfield(data,'isAFSC') == 1) && (data.isAFSA*data.isAFSC == 1)
        uisave({'x','t','D','U','S','V','T','A','C','supersetAFSA','supersetAFSC','fullAFSC','fullAFSA'},[data.PathName,'results_facpack_CAA_',data.FileName]);
    else
        uisave({'x','t','D','U','S','V','T','A','C','fullAFSC','fullAFSA'},[data.PathName,'results_facpack_CAA_',data.FileName]);
    end
else
    if (isfield(data,'isAFSA') == 1) && (isfield(data,'isAFSC') == 1) && (data.isAFSA*data.isAFSC == 1)
        uisave({'x','t','D','U','S','V','T','A','C','supersetAFSA','supersetAFSC'},[data.PathName,'results_facpack_CAA_',data.FileName]);
    else
        uisave({'x','t','D','U','S','V','T','A','C'},[data.PathName,'results_facpack_CAA_',data.FileName]);
    end 
end
