Integrating a function with one of the limits a matrix
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Alyssa Pope
el 3 de Abr. de 2021
Comentada: darova
el 4 de Abr. de 2021
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 comentarios
Respuesta aceptada
darova
el 4 de Abr. de 2021
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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!