MATLAB: Definite integral of a constant

integrationMATLAB

I'm building a code to calculate the equal area criterion, the problem is that in one part I need to integrate a constant and matlab gives me an error when trying to integrate it:
For example:
P = 1;
limit_1 = 0;
limit_2 = 10;
Area = int (P,limit_1, limit_2);
is there a way around this? if P is a function of x or something it computes it OK, but if I input a constant like in the example it doesn't work.

Best Answer

Note the difference in what I did.
P = sym(1);
limit_1 = 0;
limit_2 = 10;
Area = int (P,limit_1, limit_2)
Area =
10.0
If instead, you try something like this:
Area = int (1,limit_1, limit_2)
Undefined function 'int' for input arguments of type 'double'.
it throws an error, because int works on symbolic inputs, NOT on doubles. At least one argument must be symbolic. So this also works:
Area = int (1,0,sym(10))
Area =
10