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
2022-8-1
Note that you could pre-compute x./sum(sum(x)) since you are not changing x inside the loop
采纳的回答
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
3 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!