I try to integrate a function and plot it in Octave.
Integration itself works, i.e. I can evaluate the function
g(1.5) but plotting fails.
f = @(x) ( (1) .* and((0 < x),(x <= 1)) + (-1) .* and((1 <x),(x<=2))); g = @(x) (quadcc(f,0,x)); x = -1.0:0.01:3.0; plot(x,g(x));
But receive the following error:
quadcc: upper limit of integration (B) must be a single real scalar
As far as I can tell this is because the plot passes a vector (namely
g which passes it down to
quadcc which cannot handle vector arguments for the third argument.
So I understand what's the reason for the error but have no clue how to get the desired result instead.
N.B. This is just a simplified version of the real function I use, but the real function is also constant on a finite set of intervals ( number of intervals is less than ten if that matters). I need to integrate the real function 3 times in succession (f represents a jerk and I need to determine functions for acceleration, velocity and distance). So I cannot compute the integrals by hand like I could in this simple case.