(adsbygoogle = window.adsbygoogle || []).push({}); How to set "vector limits" when doing an integration in Matlab?

I come across a trouble when I tried to set the limits of the integration as vector:

%__________________________________________%

b=1:3;

c= quadv(@(x) x.^2+b, b, b+20);

%__________________________________________%

Then Matlab says:

??? Operands to the || and && operators must be convertible to logical scalar values.

Error in ==> quadv>quadstep at 141

if abs(h) < hmin || c == a || c == b

Error in ==> quadv at 75

[Q2,fcnt,warn2] = ...

Although quadv allows the integrand to be a vector, it seems Matlab does not allow the integration LIMITS to be a vector anyway. (In the above example, it means I cannot set the integration limits as (b, b+20) because b is a vector.)

I could have use the "for" loop as an alternative:

%__________________________________________%

b=1:3; c=b;

for i=1:numel(b)

c(i) = quadv(@(x) x.^2+b(i), b(i), b(i)+10);

end

%__________________________________________%

However, this will significantly increase the time needed to run the program because in this case all the integrations are not done simultaneously, and therefore a lot of time is wasted in doing the "for" loop.

Thus, does anyone have any suggestion in setting the integration limits as vectors?

(P.S. The above integrand is a simple example, while I am practically handling a much more complicated integrand.)

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# How to set vector limits when doing an integration in Matlab?

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads for vector limits doing |
---|

Mathematica Looping through vectorized functions for a piecewise solution |

Mathematica Cannot do the integral of the Hyper-geometric function? |

MATLAB MATLAB vector multiplication |

**Physics Forums | Science Articles, Homework Help, Discussion**