フィルターのクリア

How to integrate for each row of parameters in a matrix, rather than using a loop

1 回表示 (過去 30 日間)
Ara Jo
Ara Jo 2022 年 1 月 7 日
回答済み: Paul 2022 年 1 月 12 日
Hello,
I have been the following code to calculate an integral:
Price = @(z, pg0, pf0, epsilon) ...
(pg0.^(1-z) + pf0 .^(1-z)).^(1./(1-z)).^(1-epsilon); %
AvgPrice = integral(@(z) Price(z, pg0, pf0, epsilon), 0 ,20) ;
where pg0, pf0, epsilon are scalars. Is there a way to do this when the inputs are in a matrix, for instance when each input is a 5 by 1 matrix, to calculate the integral by using inputs from each row? So the output (AvgPrice) will also be a colum vector (5 by 1) with each element being the value of the integral? I can use a loop and run it five times but I wonder if there's a more efficient way to do it.
Thanks very much for your time!

採用された回答

Paul
Paul 2022 年 1 月 12 日
integral() can integrate a vector function of a scalar. It sounds like this is what you're looking for.
Whether or not it's more efficient is an interesting question.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangePrice and Analyze Financial Instruments についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by