MATLAB: Definite integral w/o using symbolic variable

definite integral inline quadl

I am trying to integrate a function, then store that value, then change a value in the function, integrate again, store that value, and so on.
here is the idea
x=0:10;
x1 = 2;
x2 = 5;
m = 1;
i = 1;
if m < 5
F = inline('m*x');
AUC(i) = quadl(F,x1,x2);
m = m+1;
i = i+1;
end
M=1:4;
plot(M,AUC)
obviously this code does not work. I need to update the line F=inline for every value of m. How do I do this, or is there another way?

Best Answer

  • m = 1:4;
    x1 = 2;
    x2 = 5;
    AUC = arrayfun(@(i1)quad(@(x)i1*x,x1,x2),m)
    loop
    n = numel(m);
    AUC = zeros(n,1);
    for i1 = 1:n
    AUC(i1) = quad(@(x)m(i1)*x,x1,x2);
    end
    ADD
    k = 3+4i; % e.g.

    q = 6-4i; % e.g.
    I = @(x)abs((exp(-((1i*k)/(2*q))*x.^2).^2))/2;
    quadgk(I,2,-3*1i)