When you use trapz() and supply a scalar second argument but no third argument, trapz() always interprets the argument as a dimension number. If you do not want it to be a dimension number then you must supply a third parameter containing the dimension number.
If you are trying to supply theta(i) as the spacing between points, then it would need to go as the first parameter.
Your likely mistake is in trying to call trapz() on one y point at a time. You should put all of the x and y into vectors first, and then use a single trapz() call.