solving a function iteratively , looping it with increasing values then summing those values

3 views (last 30 days)
I constructed a 'code' that essentially is a calculation of isotope production and decay via cosmic ray bombardment, in sediment over a given time, at a given depth beneath the surface of the earth. But this models instantaneous burial of the sediment and subsequent production/decay at the present depth, and I want to use the existing code to model production of isotopes during the process of slow burial, in say 1 meter/ 10,000 year increments, up to a specific depth (the burial depth of a sample), then sum those outputs. I know I need to loop this code but I haven't been able to wrap my head around the nuts and bolts of it (complete novice). I thought of solving this iteratively, anyone have recommendations? attached is the code, with lots of annotations and comments.
I think I want to loop lines 62-68 increasing z from 1 meter - say 100 m (a known burial depth) then sum the outputs (?), which in turn become input for further calculations. THANK YOU!
  2 Comments
Geoff Hayes
Geoff Hayes on 15 Oct 2014
Cody - in your code, you define z and t as
z = 16400; % sample depth in cm
t = 1377000; % time in years since
Want do you want your starting depth and starting year to be - 100 (for one metre) and 10000 (years) respectively? What should the end depth and end time be?
Do you then fix the depth and then just change the year
for z=100:100:100000 % start at 100 cm and increment by 100
for t=10000:10000:?? % start at 10000 years and increment by 10000
or fix the year and change the depth
for t=10000:10000:?? % start at 10000 years and increment by 10000
for z=100:100:100000 % start at 100 cm and increment by 100
How would you use the output, Epaleo, from one iteration, as the input for the next iteration?
C M
C M on 15 Oct 2014
Geoff, Thanks for the reply. I want to use z(t) = 9E-5 (a slow sedimentation rate), In other words, I want to vary both depth and time. I approximated this as 1 meter per 10,000 years in the question or 1E-4 cm/yr, pretty similar rates.
A starting depth of 100 cm, at time = 10,000 yrs should give a value, Npro, or number of atoms produced at z = 100 and t = 10,000. The next iteration should calculate Npro at 200 cm and 20,000 yrs, and sum the previous Npro with the newest Npro. And so on until the burial depth has been reached, which was measured in the field.
Ndec, Ninitial, and E_paleo don't need to be in the loop, (I think). Once the loop finishes, it should feed a value, Npro (the sum of all the iterations) into the next line to calculate radiogenic decay from t =0:t final, burial age of sediment.
I think what I am explaining is a differential equation, but I was looking at solving it iteratively in steps... maybe there is a better approach? Or maybe the above is easy to do?

Sign in to comment.

Answers (1)

C M
C M on 15 Oct 2014
correction... I said 'The next iteration should calculate Npro at 200 cm and 20,000 yrs, and sum the previous Npro with the newest Npro. And so on until the burial depth has been reached, which was measured in the field.' BUT, Maybe time needs to kept constant, as written here '
for t=10000:10000:?? % start at 10000 years and increment by 10000
for z=100:100:100000 % start at 100 cm and increment by 100
this way its not counting the production twice...

Categories

Find more on Oceanography and Hydrology in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!