How to convert from a for loop to a while loop
이전 댓글 표시
I need to modify the set of codes below to a while loop

댓글 수: 3
Steven Lord
2016년 12월 13일
What have you tried so far?
James Tursa
2016년 12월 13일
편집: James Tursa
2016년 12월 13일
Why do you need this converted? Is this homework? Why not get rid of the loop entirely and vectorize this operation?
Yuqing Zhu
2016년 12월 13일
편집: James Tursa
2016년 12월 13일
채택된 답변
추가 답변 (1개)
David Barry
2016년 12월 13일
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;
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
