필터 지우기
필터 지우기

how to use >,< with while loop

조회 수: 1 (최근 30일)
Navikesh Krishna
Navikesh Krishna 2019년 8월 20일
댓글: Walter Roberson 2019년 8월 20일
if i have a list of numbers and i have to use 'while' loop to determine when the list of numbers decreased by 10000 from initial value , how should i code it ?
  댓글 수: 3
Navikesh Krishna
Navikesh Krishna 2019년 8월 20일
I tried this but this didnt work :
-while altitude < 10000
-disp(altitude(1,1))
-end
1.PNG
Walter Roberson
Walter Roberson 2019년 8월 20일
hint:
idx = 1;
while idx.^3 + 5*idx.^2 - 19 < 10000
idx = idx + 1;
end
disp(idx)

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

답변 (1개)

AlexG
AlexG 2019년 8월 20일
편집: AlexG 2019년 8월 20일
Not clear what you mean by the initial value but if you mean the first value in the list that is 10000 less than its first value then you could use:
index = find(a <= a(1) - 10000, 1);
Above, a is your vector of numbers, e.g.,
a = [1:3 -10000:0];
  댓글 수: 1
Navikesh Krishna
Navikesh Krishna 2019년 8월 20일
this is my initial values given and i have to find when the values deceased by 10000
i tried : while altitude < 10000
disp(altitude(1,1))
end
but it didnt work out
1.PNG

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by