Loop with 2 diferent iterations conuntings

1 次查看(过去 30 天)
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 个评论
Jan
Jan 2022-6-6
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)]}

请先登录,再进行评论。

回答(2 个)

Voss
Voss 2022-6-28
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 2022-7-7
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 个评论
Jan
Jan 2022-7-8
编辑:Jan 2022-7-8
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.

请先登录,再进行评论。

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by