- #1

PainterGuy

- 940

- 70

- TL;DR Summary
- Why using numerical integration "integral" function is not working for me?

Hi,

I was trying to numerically integrate the following inverse Fourier transform integral,
, using the code below. The plot is also shown below.

The plot looks good which means the result is good as well. By the way, I was getting a warning which I quote below the code.

Plot #1

In the code below, I'm using "quad" function to do the numerical integration and I understand that it's a deprecated function and "integral" function should be used instead. I replaced "quad" with "integral" in the code. The "integral" function doesn't work for me as the plot below shows. Where am I going wrong? Could you please help me?

changed to

Plot #2

I was trying to numerically integrate the following inverse Fourier transform integral,

The plot looks good which means the result is good as well. By the way, I was getting a warning which I quote below the code.

Matlab:

```
% file name "fourier_transform_unit_pulse_numerical_integration.m"
% using quad function
clear all; close all; clc;
x=linspace(-8*pi,8*pi,300);
Rs_x=0.*[1:300];for i1=1:300
x1=x(i1);
f=@(w)(1/pi)*(((2*sin(pi*w)/w)*cos(x1*w)));
Rs_x(i1)=quad(f,0,60);
end
plot(x,Rs_x);
hold;
```

Code:

```
Warning: Maximum function count exceeded; singularity likely.
> In quad (line 98)
In fourier_transform_unit_pulse_numerical_integration (line 18)
```

Plot #1

Matlab:

`Rs_x(i1)=quad(f,0,60);`

Matlab:

`Rs_x(i1)=integral(f,0,60);`

Plot #2