Integrating a function with one of the limits a matrix
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!