Integrating a function with one of the limits a matrix

13 次查看(过去 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.

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by