MATLAB: How could I display the input function and its indefinite first integral (their graphs as outputs)

MATLAB: How could I display the input function and its indefinite first integral (their graphs as outputs)

beginnerengineering

Tanking in consideration that I want the range for x from -100 to 100.
Thanks so much. I appreciate it.

Best Answer

  • The integral function is going to produce one point — the value of the entire integral. If you want to plot it, use cumtrapz:
    a = 2; % Input Value

    b = 3; % Input Value
    fun = @(x) x.^2; % Create Function To Test Code
    x = linspace(a, b);
    q = cumtrapz(x,fun(x));
    fprintf('n f = %6.4fn',q(end)-q(1))
    figure(1)
    plot(x, q)
    grid
  • Add a Comment

    Your email address will not be published. Required fields are marked *