How to store loop value in array?

11 ビュー (過去 30 日間)
Vinay Sharma
Vinay Sharma 2020 年 5 月 10 日
編集済み: Ameer Hamza 2020 年 5 月 10 日
For ....
A=A+1;
End
%how can i store value A in array

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 5 月 10 日
編集済み: Ameer Hamza 2020 年 5 月 10 日
You need to use an array to store all the values. If values are scalar or vectors of constant length, then you can use simple arrays. If, in each iteration, the result is of variable length, then you will need to use cell arrays. For example
A = zeros(1, 10)
for i = 2:10
A(i) = A(i-1) + 1;
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by