# Iterations outcome summation (accumulation).

1 view (last 30 days)
jose Hlunguane on 1 Aug 2022
Commented: VBBV on 2 Aug 2022
Hi MatLab Comunity
Evaluating the failure probability based on fatigue damage, I'd like to estimate the accumulated damage by summing the outcome damages from the iterations helding.
The code:
x = [4 7 9 11 6 8 13 5 0 2 1 23;14 3 8 0 2 9 7 2 12 17 4 5;0 1 3 4 0 0 7 8 2 5 4 1];
d = 0;
for j = 1:length(x)
n = 1.0;
pause(n)
d = d + x./sum(sum(x));
fprintf(' _____iteration No %d: d %d\n', d)
D = [n', j]
end
The code performs iteration estimating damage in each 1 of 12 columns, doing print in lines. My wish is to define the command to sum these resultants.
Hope hearing from you
Walter Roberson on 1 Aug 2022
Note that you could pre-compute x./sum(sum(x)) since you are not changing x inside the loop

VBBV on 1 Aug 2022
Edited: VBBV on 1 Aug 2022
x = [4 7 9 11 6 8 13 5 0 2 1 23;14 3 8 0 2 9 7 2 12 17 4 5;0 1 3 4 0 0 7 8 2 5 4 1];
d = 0;
iter = 1;
for k = 1:size(x,1)
for j = 1:length(x)
n = 1.0;
pause(n)
d = d + x(k,j)/sum(sum(x)); % accumulated damage resultant
fprintf(' _____iteration No %d: d %f\n',iter, d)
% D = [n', j];
iter = iter+1;
end
end
_____iteration No 1: d 0.019324 _____iteration No 2: d 0.053140 _____iteration No 3: d 0.096618 _____iteration No 4: d 0.149758 _____iteration No 5: d 0.178744 _____iteration No 6: d 0.217391 _____iteration No 7: d 0.280193 _____iteration No 8: d 0.304348 _____iteration No 9: d 0.304348 _____iteration No 10: d 0.314010 _____iteration No 11: d 0.318841 _____iteration No 12: d 0.429952 _____iteration No 13: d 0.497585 _____iteration No 14: d 0.512077 _____iteration No 15: d 0.550725 _____iteration No 16: d 0.550725 _____iteration No 17: d 0.560386 _____iteration No 18: d 0.603865 _____iteration No 19: d 0.637681 _____iteration No 20: d 0.647343 _____iteration No 21: d 0.705314 _____iteration No 22: d 0.787440 _____iteration No 23: d 0.806763 _____iteration No 24: d 0.830918 _____iteration No 25: d 0.830918 _____iteration No 26: d 0.835749 _____iteration No 27: d 0.850242 _____iteration No 28: d 0.869565 _____iteration No 29: d 0.869565 _____iteration No 30: d 0.869565 _____iteration No 31: d 0.903382 _____iteration No 32: d 0.942029 _____iteration No 33: d 0.951691 _____iteration No 34: d 0.975845 _____iteration No 35: d 0.995169 _____iteration No 36: d 1.000000
VBBV on 2 Aug 2022