Filling a array/matrix without for-loop

2 ビュー (過去 30 日間)
Joschua Kraus
Joschua Kraus 2018 年 1 月 14 日
回答済み: BhaTTa 2024 年 10 月 21 日
array = zeros(1, 20);
for i = 1:20
array(1,i) = %some formula dependent upon i, e.g. (i-1)*value1*value2/value3
end
Desired: A way to do it without the for-loop. I know it's probably out there yet but I didn't find it via the google or searching the forum. Sorry for possible duplicate.

回答 (1 件)

BhaTTa
BhaTTa 2024 年 10 月 21 日
Hey @Joschua Kraus, you can make use of vectorizied operations in MATLAB.
Please refer to this documentation.

カテゴリ

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