Loop with 2 diferent iterations conuntings

조회 수: 1 (최근 30일)
jose Hlunguane
jose Hlunguane 2022년 6월 6일
편집: Jan 2022년 7월 8일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Waveform Generation에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by