Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Problems about using the fourier() and ifourier() to get the variables convolution

Subject: Problems about using the fourier() and ifourier() to get the variables convolution

From: Yung Olivier

Date: 16 Jun, 2010 08:37:11

Message: 1 of 6

Hey:
      Everybody, I got a problem about the variables convolution, the condition is as follow:
      a(x),b(x),c(x) are all the functions in the space domain, assume that c(x) = conv(a(x),b(x)), x is symbolic. In MATLAB, I want to use the method of "ifourier(fourier(a)*fourier(b))" to get c(x);
      In theory, it should be feasible, but it occures one problem when I did that : the answer contained two variables, which were w and x. I just can‘t understand why. Can somebody give me a help, thank you very much!
   
     PS: At first, I considered to use the inner function conv() to calculate the convolution, but after trying I knew conv() is for discrete value, and if anybody knows another method to do the variable, please tell me, thanks again!!
      
     The test model is as follow, hope it can show the problem more clearly:
clc
clear
syms x w
U=fourier(exp(x^2*1i), x, w);
%%findsym(U) %%to find syms in U
t=heaviside(x-1)-heaviside(x+1);
T=fourier(t, x, w);
%%findsym(T)
S=U*T;
%%findsym(S)
s=ifourier(S,w,x);
%findsym(s)

                                                                                                            Olivier

Subject: Problems about using the fourier() and ifourier() to get the variables convolution

From: David Young

Date: 16 Jun, 2010 09:21:03

Message: 2 of 6

I'm not sure what you mean by saying that conv is for discrete values. All numerical computations are with discrete values.

You can do a discrete 1-D convolution with either conv or the Fourier transform. To get the same answer, you need to bear in mind that the FT automatically uses periodic boundary conditions, so you need to set these up for conv. If you think about the indexing (easiest if you experiment with some small examples), you'll find that the outputs are shifted by one place relative to one another; you can easily correct for this as is done below.

Some test data:

  N = 1024;
  a = rand(1, N);
  b = rand(1, N);

The convolution of a and b using conv:

  c_conv = conv([a a], b, 'valid'); % [a a] sets up periodic boundary conds
  c_conv(1) = []; % make c_conv(i) refer to offset i; offset 0 is at c_conv(N)

The same using the FT:

  af = fft(a);
  bf = fft(b);
  cf = af .* bf;
  c_fft = ifft(cf);

A check that the results are the same:

  disp(max(abs(c_conv - c_fft)));

which prints out something less than 10^-12 on my system, so there's agreement to within machine precision.

The choice between conv and the FT is therefore mainly one of efficiency. If a and b are the same size, as here, the FT will be faster. If one is much smaller than the other, then conv will be faster.

Subject: Problems about using the fourier() and ifourier() to get the variables convolution

From: David Young

Date: 16 Jun, 2010 09:29:05

Message: 3 of 6

I've just had another look, and realise that your question maybe refers to the Symbolic Math Toolbox. If that's the case, obviously you can ignore my reply!

Subject: Problems about using the fourier() and ifourier() to get the variables convolution

From: Mokdad Mokdad

Date: 27 Aug, 2012 14:29:17

Message: 4 of 6

hello
I got the same problem as you posted about the convolution of tow functions.
theoretically we can use the Fourier transformation :
conv( a , b ) = "ifourier(fourier(a)*fourier(b))"
I tried to do this with matlab, but I did not do it ... the answer contained two variables, in the from of integration over one (from -inf .. +inf)
pleas.. if you find the good result of the convolution of the functions ... or if you understand the result returned by tel matlab for the "ifourier(fourier(a)*fourier(b))" expression... pleas help me... this is my email mokdad.a@gmail.com
thank you...

Subject: Problems about using the fourier() and ifourier() to get the

From: Christopher Creutzig

Date: 30 Aug, 2012 06:59:05

Message: 5 of 6

On 27.08.12 16:29, Mokdad Mokdad wrote:
> hello
> I got the same problem as you posted about the convolution of tow functions.
> theoretically we can use the Fourier transformation :
> conv( a , b ) = "ifourier(fourier(a)*fourier(b))"

That is true if a and b are symbolic expressions and the default choice
of variables for the fourier and ifourier calls happens to match your
intentions, yes.

> I tried to do this with matlab, but I did not do it ... the answer contained two variables, in the from of integration over one (from -inf .. +inf)

The Fourier transform may not have a closed form representation, and if
it has, the computer may still not be able to find it. Unfortunately,
you did not give complete input to reproduce what you saw, so it's
difficult to say anything beyond that.


Christopher

Subject: Problems about using the fourier() and ifourier() to get the variables convolution

From: Mokdad Mokdad

Date: 1 Sep, 2012 21:14:08

Message: 6 of 6

hello every body

I tried with matlab to comput convolution function of two other functions, and I had same problems using fourier transformation function,
I tried to do it without the fourier transformations, but directly with application of the definition of convolution of two functions using the integral ( function int of matlab)... and it work for many cases, but not for all cases...
thank you ....
Mokdad





"Yung Olivier" <gyolive@qq.com> wrote in message <hva2fn$hcb$1@fred.mathworks.com>...
> Hey?
> Everybody, I got a problem about the variables convolution, the condition is as follow:
> a(x),b(x),c(x) are all the functions in the space domain, assume that c(x) = conv(a(x),b(x)), x is symbolic. In MATLAB, I want to use the method of "ifourier(fourier(a)*fourier(b))" to get c(x);
> In theory, it should be feasible, but it occures one problem when I did that : the answer contained two variables, which were w and x. I just can‘t understand why. Can somebody give me a help, thank you very much!
>
> PS: At first, I considered to use the inner function conv() to calculate the convolution, but after trying I knew conv() is for discrete value, and if anybody knows another method to do the variable, please tell me, thanks again!!
>
> The test model is as follow, hope it can show the problem more clearly:
> clc
> clear
> syms x w
> U=fourier(exp(x^2*1i), x, w);
> %%findsym(U) %%to find syms in U
> t=heaviside(x-1)-heaviside(x+1);
> T=fourier(t, x, w);
> %%findsym(T)
> S=U*T;
> %%findsym(S)
> s=ifourier(S,w,x);
> %findsym(s)
>
> Olivier

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us