Iterations outcome summation (accumulation).
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
jose Hlunguane
el 1 de Ag. de 2022
Comentada: VBBV
el 2 de Ag. de 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
1 comentario
Walter Roberson
el 1 de Ag. de 2022
Note that you could pre-compute x./sum(sum(x)) since you are not changing x inside the loop
Respuesta aceptada
VBBV
el 1 de Ag. de 2022
Editada: VBBV
el 1 de Ag. de 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
3 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Mathematics and Optimization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!