I have an integral expression which I defined on Matlab using
x = 0:1/1000:1;
g = @(x) (exp(-1./x.^2).*heaviside(x)).*(exp(-1./(1-x).^2).*heaviside(1-x));
t = 0:1/1000:1;
f = zeros(size(t));
for i = 1:length(t)
f(i) = integral(g,0,t(i));
end
I can plot it, for example, using plot(t,f)
, but for other purposes I would like to attach a function handle to f
, i.e. something like f = @(t) zeros(size(t))
. I have not been able to figure it out thus far. f = @(t) integral(@(x)g(x),0,t)
is also not sufficient.