`function int=calculateintegral(from,to,subinterval)inttemp=0;if rem(subinterval,2)>0 int='subinterval must be devidable on two'elsefor x=from+subinterval:subinterval*2:to-subinterval y1=4*exp(-(x)^2) y2=2*exp(-(x+((to-from)/subinterval))^2) inttemp=inttemp+y1+y2endendint=inttemp`

when i ran it in matlab it does not seem to loop through the for-loop or the if-condition:

>> calculateintegral(0,1,1000)

int =

` 0`

ans =

` 0`

>> calculateintegral(0,1,1001)

int =

` 0`

ans =

` 0`

## Best Answer