Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Matlab のCVXコードでsymsum の代わりに使用できる代替品は何ですか? ループを使用せずに二重加算を使用したいのですが、symsum が唯一の利用可能なオプションのようです。
関数をベクトル化できる場合は、次を使用するsumのが最も速い方法です。
sum
sum([1:10].^2) %sum all squares from 1 to 10
これが不可能な場合は、arrayfun と sum を組み合わせます。
f=@(x)(x^2) sum(arrayfun(f,1:10))%sum all squares from 1 to 10