Iterations outcome summation (accumulation).

1 visualización (últimos 30 días)
jose Hlunguane
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
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

Iniciar sesión para comentar.

Respuesta aceptada

VBBV
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
_____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 comentarios
jose Hlunguane
jose Hlunguane el 1 de Ag. de 2022
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
VBBV
VBBV el 2 de Ag. de 2022
Please accept the answer if it helped

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Linear Model Identification en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by