I find it difficult to follow your Beer’s law implementation.
That aside, your problem is likely here:
t=logspace(1,10000,10000);
Please see the documentation for the logspace function. You are asking it to create a vector from 10^1 to 10^10000. Only the first 308 elements of your vector are finite.
The solution is to decrement ‘t’ using the linspace function:
L=1; %cm
e=117000; %extinction coefficient
m=1; %mass of dye to be used in mg
w=407.99; % molar weight of dye in mg/mmol
v=100; %volume of ccl4 in ml
c=m/(v*w); %molarity mmol/ml
t=linspace(10,1,250);
i=0;
A=0;
d = 0;
Adt = [];
while A < 1
A=e*L*d;
i=i+1;
d=c./t(i);
Adt = [Adt; A d t(i)];
end
Result = Adt(end-1:end, :)
Result =
0.9959 8.6202e-06 2.8434
1.0086 8.7312e-06 2.8072
I’m not quite sure what output you want. This records ‘A’, ‘d’, and ‘t’, and prints them for the last two steps.
