function [A,b] = ssnormal(rv,c) % Construct normal equations for spectral disentangling problem. % This routine works. % % by D. Holmgren, April 12 94. holmgren@phobos.astro.uwo.ca % Input data... nl = input(' Length of spectra: '); mrv = input(' Number of spectra: '); % set up arrays... a11 = zeros(nl,nl); a12 = a11; a22 = a11; c1 = zeros(nl,1); c2 = zeros(nl,1); % i1,i2 will point to start and end of spectra in % vector c... i1 = 1; i2 = nl; for i = 1:mrv % get appropriate rv differences... rva = rv(i,1); rvb = rv(i,2); % get corresponding spectrum... ci = zeros(nl,1); ci = c(i1:i2); % generate matrices Na, Nb... na = ssmat2(nl,rva); nb = ssmat2(nl,rvb); % add these onto normal equations... a11 = a11 + na' * na; a22 = a22 + nb' * nb; a12 = a12 + na'* nb; % and the RHS... c1 = c1 + na' * ci; c2 = c2 + nb' * ci; i1 = i1 + nl; i2 = i2 + nl; end % construct normal equation matrix and RHS vector... A = [a11, a12; a12, a22]; b = [c1; c2];