Loop with 2 diferent iterations conuntings

1 visualizzazione (ultimi 30 giorni)
jose Hlunguane
jose Hlunguane il 6 Giu 2022
Modificato: Jan il 8 Lug 2022
I intend to make a loop that performs two counts in parallel:
1) i, must count the total number of iterations;
2) ii, must count only the iterations under the condition: H[D(t)] <= 0; {H[D(t)] = Delta - E[D(t)]}
I'm having trouble matching/synchronizing the iterations.
iterations = i + n; %
%Calculation of accumulated fatigue damage
for i = 1:iterations
.
.
.
%accumulated fatigue damage estimate
D_t = dLTi.*operationtime;
fprintf('result %i\n', D_t);
end
ii = ii + 1;
%performance function evaluation
for ii = 1:iterations
expecteddamage = (D_t + D_E)./i;
%Limit State Function evaluation
limitsfunction = Delta - expecteddamage;
fprintf('result %d\n', limitsfunction);
%failure condition checking
if limitsfunction <= 0
fprintf('system failed %Delta is smaller than.\n', expecteddamage);
end
  1 Commento
Jan
Jan il 6 Giu 2022
Please do not invent your own notation and expect, that others can guess, what is meant.
What does this mean: H[D(t)] <= 0; {H[D(t)] = Delta - E[D(t)]}

Accedi per commentare.

Risposte (2)

Voss
Voss il 28 Giu 2022
total_count = 0;
conditional_count = 0;
max_iter = 10000;
for iter = 1:max_iter
total_count = total_count + 1;
if isprime(iter)
conditional_count = conditional_count + 1;
end
end
disp(total_count);
10000
disp(conditional_count);
1229

jose Hlunguane
jose Hlunguane il 7 Lug 2022
Ooh Jan, sorry though!
H[D(t)] - stand for limit state function dependent on D(t) accumulated fatigue damage;
Delta - is the system material resistence: Delta = 1;
E[D(t)] - is the expected fatigue damage
  1 Commento
Jan
Jan il 8 Lug 2022
Modificato: Jan il 8 Lug 2022
Again: While the physical meaning of the values does not matter, the notation "H[D(t)]" is not defined. In Matlab [ ] is the concatenation operator for arrays. Of course you know, what the square brackets and curly braces should mean in your question, but the readers cannot guess this.
Prefer the standard Matlab syntax, because you can expect it to be known in a Matlab forum.

Accedi per commentare.

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by