MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# Error with ’quad‘！！！Doubleintegral?

Asked by wang on 31 Jan 2013
```L = 3.128438e+003；
```
```B= 16685；
```
```X = 2.085625e+003；
```
```Y = 0；
```
```Z = 0；
```
```Quad_1 = @(Zeta,Xi) exp(-sqrt(Xi.^2 + Zeta.^2 + Z^2))./(-sqrt(Xi.^2 + Zeta.^2 + Z^2));
```
```T_1 = quad(@(Zeta) Quad_1,Y-B,Y+B);
```
```T_2 = @(Xi) exp(-Xi)*T_1;
```
```T = quad(@(Xi) T_2(Xi), X-L, X+L);
```
```disp(T);
```
``` Error using ==> quad at 80
The integrand function must return an output vector of the same length as the input vector
Error in ==> stationaer at 75

Can anyone help me to correct the errors? Thanks.

Jack

## Products

No products are associated with this question.

Answer by proecsm on 1 Feb 2013

```L = 3.128438e+003;
B= 16685;
X = 2.085625e+003;
Y = 0;
Z = 0;
Quad_1 = @(Zeta,Xi) exp(-sqrt(Xi.^2 + Zeta.^2 + Z^2))./(-sqrt(Xi.^2 + Zeta.^2 + Z^2));
%T_2 = @(Xi) exp(-Xi)*T_1;
%T = quad(@(Xi) T_2(Xi), X-L, X+L);
disp(T);
```

## 1 Comment

wang on 1 Feb 2013

thanks for your answer. but the equa, that i want to have is like:

integral[_ exp(-Xi)*_integral{ exp(-sqrt(Xi^2 + Zeta^2 + Z^2))/(-sqrt(Xi^2 + Zeta^2 + Z^2))} ]

there is an exp(-Xi) before the second integral.

Answer by wang on 1 Feb 2013

thanks for your answer. but the equa, that i want to have is like:

integral[_ exp(-Xi)*_integral{ exp(-sqrt(Xi^2 + Zeta^2 + Z^2))/(-sqrt(Xi^2 + Zeta^2 + Z^2))} ]

there is an exp(-Xi) before the second integral.