From: Yung Olivier on 16 Jun 2010 04:37 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
From: David Young on 16 Jun 2010 05:21 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.
From: David Young on 16 Jun 2010 05:29 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!
|
Pages: 1 Prev: embedded MatLab function error Next: plot graphs above each other |