this will solve the problem:
fun = @(x) 5;
integral(fun,0,1,'ArrayValued',true)
according to Mathworks: Array-valued function flag, specified as the comma-separated pair consisting of 'ArrayValued' and either false, true, 0, or 1. Set this flag to true when you want to integrate over an array-valued function. The shape of fun(x) can be a vector, matrix, or N-D array.
Example: 'ArrayValued',true indicates that the integrand is an array-valued function.