Loop with 2 diferent iterations conuntings

1 view (last 30 days)
jose Hlunguane
jose Hlunguane on 6 Jun 2022
Edited: Jan on 8 Jul 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 Comment
Jan
Jan on 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)]}

Sign in to comment.

Answers (2)

Voss
Voss on 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);
10000
disp(conditional_count);
1229

jose Hlunguane
jose Hlunguane on 7 Jul 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 Comment
Jan
Jan on 8 Jul 2022
Edited: Jan on 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.

Sign in to comment.

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!