My intention with the following code:
step = 0.1;
time = Table[i, {i, 0, 100, step}];
T = Table[0, {i, Length[time]}];
tt = Prepend[T, 90];
temp = 0;
Do[
tr = tt[[i]]+temp;
temp = ((tr + 273.15) - time[[i+1]]) - 273.15
// Print, {i, 1, 100, 1}
]
is to have tr
to be updated each time as if you were reading it line by line. In other words, to have tr
to be in the first iteration 90, and then in the following iterations whatever the value of temp
is in each iteration. As an example, for the first iteration temp
should be temp = ((90 + 273.15) - 0.1) - 273.15 =89.9
. In the second iteration temp
should be temp = ((89.9 + 273.15) - 0.2) - 273.15 =89.7
. In the third iteration temp
should be temp = ((89.7 + 273.15) - 0.3) - 273.15 =89.4
and so on. I am do not think the do loop
is the appropiate loop for this but I am not what would be the best strategy for this. I appreciate your inputs in advanced
{89.9, 89.7, 89.4, 89., 88.5, 87.9, 87.2, 86.4, 85.5, 84.5,etc....}
or something else? Answer below gives the above. May be you can give a small explicit example (sayi=1..3
only and show what list should the loop generate. This is easier than describing with words. $\endgroup$temp=((tr + 273.15) - time[[i+1]]) - 273.15
by using updatingtr
each time. So that in the first iterationtr=90
, in the secondtr=temp
, in the thirdtr=temp
and so on. So I want 'tr' to be 90 at first by then to get the value oftemp
after the second iteration. I hope that helps clarify it $\endgroup${i, 1, 3 1}
instead of using words to describe things. This will make things much more clear. $\endgroup$temp
is compute it (which the other code happens to get the answer to but it does not computetemp
) $\endgroup$i=i
temp
will generate 89.9, fori=2
temp
will generate 89.7, fori=3
temp
will generate 89.4. It would do so by having 'tr' to be 90 fori=i
tr=temp
for any iteration after that. $\endgroup$