How do i save values for each iteration ?
1 回表示 (過去 30 日間)
古いコメントを表示
clc
clear
for a = [0.01 0.01 0.01 0.03 0.1 0.2 0.3 0.3 0.3 0.4 0.4 0.4 0.3 0.4 0.5 0.8 0.9 1 0.8 0.7 0.5 0.2 0.1 0.03];
b=a*5
end
How can I store new values of b for each iteration ?
1 件のコメント
採用された回答
David Hill
2021 年 4 月 16 日
a = [0.01 0.01 0.01 0.03 0.1 0.2 0.3 0.3 0.3 0.4 0.4 0.4 0.3 0.4 0.5 0.8 0.9 1 0.8 0.7 0.5 0.2 0.1 0.03];
for k= 1:length(a)
b(k)=a(k)*5;%index into b
end
Better, just multiply, no loop needed.
b=5*a;
0 件のコメント
その他の回答 (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!