Hello everyone,
What is the alternative of while loop for the example:
rate = 2;
while (k <= period)
sum = sum + array(k,2);
k = k + rate;
end
Thanks.

 채택된 답변

Fabio Freschi
Fabio Freschi 2019년 11월 17일

1 개 추천

I don't know the starting value of k, assuming it is 1
idx = 1:rate:period
mysum = sum(array(idx,2)); % note that sum is the name of a matlab function

댓글 수: 1

cglr
cglr 2019년 11월 18일
편집: cglr 2019년 11월 18일
Thank you.
maxDuration = 0;
while (k <= period)
if( myArray (k,2) > maxDuration)
maxDuration = myArray (k,2);
end
k = k + rate;
end
If I make it more complex with if statement like that, how can I use that idea ?

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Sensor Models에 대해 자세히 알아보기

질문:

2019년 11월 17일

편집:

2019년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by