How to convert from a for loop to a while loop
Ältere Kommentare anzeigen
I need to modify the set of codes below to a while loop

3 Kommentare
Steven Lord
am 13 Dez. 2016
What have you tried so far?
James Tursa
am 13 Dez. 2016
Bearbeitet: James Tursa
am 13 Dez. 2016
Why do you need this converted? Is this homework? Why not get rid of the loop entirely and vectorize this operation?
Yuqing Zhu
am 13 Dez. 2016
Bearbeitet: James Tursa
am 13 Dez. 2016
Akzeptierte Antwort
Weitere Antworten (1)
David Barry
am 13 Dez. 2016
This does not need to be any kind of loop. You should learn about logical indexing in MATLAB. This can be done with one line of code.
Vector(Vector >=0) = Vector(Vector >=0) * 2;
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
