Does Matlab’s integral function pass the integration variable to the function handle one scalar at a time or as a vector?
Hello,
My integrand function contains a sum that depends on the integration variable, as follows:
tau = 1;
T = 20;
q = integral(@(t) f(t,tau),0,T)
function y = f(t,tau)
N = 0:floor(t,tau)
for i = 1:length(N)
n = N(i);
y = y + g(n,mod(t,tau) + (n+1)*tau) – g(n,mod(t,tau) + n*tau);
end
Where g is some function.
I’m not sure if the integral function is handling it correctly, because if it passes a vector t, the sum will not iterate over the correct range.
I would really appreciate any insights!
Thanks!Hello,
My integrand function contains a sum that depends on the integration variable, as follows:
tau = 1;
T = 20;
q = integral(@(t) f(t,tau),0,T)
function y = f(t,tau)
N = 0:floor(t,tau)
for i = 1:length(N)
n = N(i);
y = y + g(n,mod(t,tau) + (n+1)*tau) – g(n,mod(t,tau) + n*tau);
end
Where g is some function.
I’m not sure if the integral function is handling it correctly, because if it passes a vector t, the sum will not iterate over the correct range.
I would really appreciate any insights!
Thanks! Hello,
My integrand function contains a sum that depends on the integration variable, as follows:
tau = 1;
T = 20;
q = integral(@(t) f(t,tau),0,T)
function y = f(t,tau)
N = 0:floor(t,tau)
for i = 1:length(N)
n = N(i);
y = y + g(n,mod(t,tau) + (n+1)*tau) – g(n,mod(t,tau) + n*tau);
end
Where g is some function.
I’m not sure if the integral function is handling it correctly, because if it passes a vector t, the sum will not iterate over the correct range.
I would really appreciate any insights!
Thanks! integral MATLAB Answers — New Questions