function AddAllDataToBinsR2(bin, binL, binU, obs)

global 	gB1DataFlag...
		gB2DataFlag...
		gB3DataFlag...
		gB4DataFlag...
		gB5DataFlag...
		gB6DataFlag...
		gC1DataFlag...
		gC2DataFlag...
		gC3DataFlag...
		gB7NPDataFlag...
		gCNPDataFlag;
		
global 	gB1Data...
		gB2Data...
		gB3Data...
		gB4Data...
		gB5Data...
		gB6Data...
		gC1Data...
		gC2Data...
		gC3Data...
		gB7NPData...
		gCNPData;
		
global 	gB1InvStokesM...
	 	gB2InvStokesM...
	 	gB3InvStokesM...
	 	gB4InvStokesM...
	 	gB5InvStokesM...
	 	gB6InvStokesM...
	 	gC1InvStokesM...
	 	gC2InvStokesM...
	 	gC3InvStokesM;
		
global 	gAverageCimelFlag;

	% Place data for specified bands into the corrent bin

if gB1DataFlag == 1
	stokesV(1:3) = gB1InvStokesM * [obs(26); obs(27); obs(28)];
	stokesV(4) = DegOfPolarization(stokesV(1:3));
	stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
	
	for j=1:5
		for i=binL:binU
			gB1Data(i,j) = gB1Data(i,j) + stokesV(j);
			end;
		
		end;
	end;
				
if gB2DataFlag == 1
	stokesV(1:3) = gB2InvStokesM * [obs(8); obs(9); obs(10)];
	stokesV(4) = DegOfPolarization(stokesV(1:3));
	stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
	
	for j=1:5
		for i=binL:binU
			gB2Data(i,j) = gB2Data(i,j) + stokesV(j);
			end;
		
		end;
	end;
				
if gB3DataFlag == 1
	stokesV(1:3) = gB3InvStokesM * [obs(22); obs(23); obs(24)];
	stokesV(4) = DegOfPolarization(stokesV(1:3));
	stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
	
	for j=1:5
		for i=binL:binU
			gB3Data(i,j) = gB3Data(i,j) + stokesV(j);
			end;
			
		end;
	end;
				
if gB4DataFlag == 1
	stokesV(1:3) = gB4InvStokesM * [obs(15); obs(16); obs(17)];
	stokesV(4) = DegOfPolarization(stokesV(1:3));
	stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
	
	for j=1:5
		for i=binL:binU
			gB4Data(i,j) = gB4Data(i,j) + stokesV(j);
			end;
			
		end;
	end;
				
if gB5DataFlag == 1
	stokesV(1:3) = gB5InvStokesM * [obs(19); obs(20); obs(21)];
	stokesV(4) = DegOfPolarization(stokesV(1:3));
	stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
	
	for j=1:5
		for i=binL:binU
			gB5Data(i,j) = gB5Data(i,j) + stokesV(j);
			end;
			
		end;
	end;
				
if gB6DataFlag == 1
	stokesV(1:3) = gB6InvStokesM * [obs(12); obs(13); obs(14)];
	stokesV(4) = DegOfPolarization(stokesV(1:3));
	stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
	
	for j=1:5
		for i=binL:binU
			gB6Data(i,j) = gB6Data(i,j) + stokesV(j);
			end;
			
		end;
	end;
	
if gAverageCimelFlag == 1
	if gC1DataFlag == 1
		stokesV(1:3) = gC1InvStokesM * [obs(38); obs(39); obs(40)];
		stokesV(4) = DegOfPolarization(stokesV(1:3));
		stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
	
		for j=1:5
			for i=binL:binU
				gC1Data(i,j) = gC1Data(i,j) + stokesV(j);
				end;
				
			end;
		end;	% if gC1DataFlag == 1
				
	if gC2DataFlag == 1
		stokesV(1:3) = gC2InvStokesM * [obs(32); obs(33); obs(34)];
		stokesV(4) = DegOfPolarization(stokesV(1:3));
		stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
		
		for j=1:5
			for i=binL:binU
				gC2Data(i,j) = gC2Data(i,j) + stokesV(j);
				end;
				
			end;
		end;	% if gC2DataFlag == 1
				
	if gC3DataFlag == 1
		stokesV(1:3) = gC3InvStokesM * [obs(35); obs(36); obs(37)];
		stokesV(4) = DegOfPolarization(stokesV(1:3));
		stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
		
		for j=1:5
			for i=binL:binU
				gC3Data(i,j) = gC3Data(i,j) + stokesV(j);
				end;
				
			end;
		end;	% if gC3DataFlag == 1

else	%gAverageCimelFlag ~= 1
	if gC1DataFlag == 1
		stokesV(1:3) = gC1InvStokesM * [obs(38); obs(39); obs(40)];
		stokesV(4) = DegOfPolarization(stokesV(1:3));
		stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
		
		for j=1:5
			gC1Data(bin,j) = gC1Data(bin,j) + stokesV(j);
			
			end;
		end;	% if gC1DataFlag == 1
				
	if gC2DataFlag == 1
		stokesV(1:3) = gC2InvStokesM * [obs(32); obs(33); obs(34)];
		stokesV(4) = DegOfPolarization(stokesV(1:3));
		stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
		
		for j=1:5
			gC2Data(bin,j) = gC2Data(bin,j) + stokesV(j);
			
			end;
		end;	%  if gC2DataFlag == 1
				
	if gC3DataFlag == 1
		stokesV(1:3) = gC3InvStokesM * [obs(35); obs(36); obs(37)];
		stokesV(4) = DegOfPolarization(stokesV(1:3));
		stokesV(5) = AngOfPolarizedPlane(stokesV(1:3));
		
		for j=1:5
			gC3Data(bin,j) = gC3Data(bin,j) + stokesV(j);
			
			end;
		end;	%  if gC3DataFlag == 1
		
end;	% if gAverageCimelFlag == 1, else...
				
if gB7NPDataFlag == 1
	for i=binL:binU
		gB7NPData(i,1) = gB7NPData(i,1) + obs(11);
		gB7NPData(i,2) = gB7NPData(i,2) + obs(18);
		gB7NPData(i,3) = gB7NPData(i,3) + obs(25);
		end;
	end;
				
if gCNPDataFlag == 1
	obsStartIndex = 29;
	for j=1:3
		gCNPData(bin,j) = gCNPData(bin,j) + obs(obsStartIndex);
		obsStartIndex = obsStartIndex + 1;
		end;
	end;
