while loops and vectors
9 ビュー (過去 30 日間)
古いコメントを表示
hello everyone
Is there a way to store the answers from a while loop in a vector?? Id like to know how to do that. I know its possible with for loops
thank you
0 件のコメント
採用された回答
Star Strider
2014 年 9 月 14 日
It is. You simply have to create a counter:
k1 = 1;
x = 0;
while x < 25
x = k1^2; % Calculate ‘x’
y(k1) = x; % Store the value of ‘x’ in vector ‘y’
k1 = k1 + 1; % Increment counter
end
その他の回答 (0 件)
参考
カテゴリ
Help Center および 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!