while command in matlab
1 ビュー (過去 30 日間)
Jordan Monthei 2013 年 5 月 8 日
編集済み: Jordan Monthei 2013 年 5 月 8 日
A while statement operates as follows:
As such, if you were to have a while loop with a condition that your product is less than your maximum N, it will run the loop until the product exceeds N at which point the condition is met.
Within the loop then, you would want to have the number continue to multiply as long as it is running. This would leave you with something as follows:
n = 1;
Product = 1;
while( Product < N )
Product = Product * (2*n);
n = n + 1;
with that you could have some variable that increments every time the while statement goes through in order to count how many iterations occur until you exceed your maximum.