Loop with 2 diferent iterations conuntings
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Jan
am 6 Jun. 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)]}
Antworten (2)
Voss
am 28 Jun. 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);
disp(conditional_count);
0 Kommentare
jose Hlunguane
am 7 Jul. 2022
1 Kommentar
Jan
am 8 Jul. 2022
Bearbeitet: Jan
am 8 Jul. 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.
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!