How can I apply the loop method for this program ?
古いコメントを表示
I want create a program that continuously asks the user to enter numbers until the user enters a negative number. The numbers before the last one (non-negative numbers) are saved in a vector B. Then I want to display B and the average value in B. For instance, if the user enters 3, 5, 0, 7, 11, -3, the input stops and B is [3, 5, 0, 7, 11]. The average value of B is 5.2.
I know how to do it with the built-in functions of Matlab, but can not figure out how to do it with the loop method. Help !
Thanks,
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および 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!