how to use >,< with while loop
Mostra commenti meno recenti
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 Commenti
the cyclist
il 20 Ago 2019
Sounds like a school assignment. Folks here will generally be happy to help if you show what you tried so far, and ask specific questions where you are stuck.
Navikesh Krishna
il 20 Ago 2019
Walter Roberson
il 20 Ago 2019
hint:
idx = 1;
while idx.^3 + 5*idx.^2 - 19 < 10000
idx = idx + 1;
end
disp(idx)
Risposte (1)
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 Commento
Navikesh Krishna
il 20 Ago 2019
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

