Iterations outcome summation (accumulation).

1 次查看(过去 30 天)
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
  1 个评论
Walter Roberson
Walter Roberson 2022-8-1
Note that you could pre-compute x./sum(sum(x)) since you are not changing x inside the loop

请先登录,再进行评论。

采纳的回答

VBBV
VBBV 2022-8-1
编辑:VBBV 2022-8-1
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
  3 个评论
jose Hlunguane
jose Hlunguane 2022-8-1
Thank you very much for the quick reaction.
This suggestion allows me to take significant steps, as the interactions occur separately along each column (each column represents a sea state pattern).
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];
King regards

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by