Integrating a function with one of the limits a matrix

2 ビュー (過去 30 日間)
Alyssa Pope
Alyssa Pope 2021 年 4 月 3 日
コメント済み: darova 2021 年 4 月 4 日
Hi, just needing some help on integrating this function. I have a function that I'm trying to integrate in terms of y, and one of the bounds on the integral is a matrix that I also calculate within the code. Here is my current code:
r = 350;
S = 0.001;
T = 2400;
t = [1:1:100];
u = ((r^2)*S)./(4*T.*t);
syms y
f = exp(-y)./(y);
integralCalculated = integral(@(y)exp(-y)./(y),u,inf);
So the idea is that I'm integrating from u to infinity where u has 100 components, so that I'll get an output of a matrix that also has 100 values. I get the error that A and B must be floating point scalars, and I've seen some threads that use arrayfun but wasn't clear on how it applies to the function I'm using. Thanks for any help.

採用された回答

darova
darova 2021 年 4 月 4 日
Why don't just use for loop?
integralCalculated = zeros(size(u));
for i = 1:length(u)
integralCalculated(i) = integral(@(y)exp(-y)./(y),u(i),inf);
end
  2 件のコメント
Alyssa Pope
Alyssa Pope 2021 年 4 月 4 日
That worked! Thank you very much!
darova
darova 2021 年 4 月 4 日
my pleasure

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by