% Jon Newman
% Find volumes of stock CNQX to add to get the desired concentration in
% your dish
% 
% This assumes that for each addition, you are increasing the volume of the
% dish's media by V_add

V_dish = 1000; % uL, original volume
C_dish = [1 5 10 20 40]; % uM

C_stock = 500; % mM
V_add = [0]; % The volumes of stock to add
totalM = [0]; % Molarity after each addition, should match C_dish
totalV = [V_dish];
V_o = V_dish; 

for i = 1:length(C_dish)
    V_add_naive = (V_dish*C_dish(i))/(C_stock-C_dish(i));
    
    V_add = [V_add V_add_naive - sum(V_add)];
    
    V_o = V_o + V_add(i+1); % Make the addition
    totalV = [totalV V_o];
    
    totalM = [totalM (sum(V_add)*C_stock)./V_o]; % see how much solute per total volume
    
   
end

totalV    
V_add = V_add(2:end)
totalM = totalM(2:end)
