DSPRelated.com
Forums

deconvolution problem

Started by sofiyya September 23, 2009
Hi,

I have a problem with vector deconvolution. This is what I do in Matlab:

>> vect1=[1 2 3 4 5 6 7 8 9]; >> vect2=[1 2 3 4 0 0 0 0 0 0 0 0 0 0]; %I want to find w with
conv(w,vect1)=vect2
>> Lx=length(vect2)-length(vect1)+1; >> Lx2=pow2(nextpow2(Lx)); >> VECT1=fft(vect1,Lx2); >> VECT2=fft(vect2,Lx2); >> W=VECT2 ./ VECT1; >> w=real(ifft(W,Lx2)); >> w=w(1:1:Lx); >> w=w/max(abs(w)); >> conv(w,vec1) give this result
ans = Columns 1 through 9 -0.1688 -0.5065 -1.0130 -1.6883 -1.3636 -0.9740 -0.5844 -0.1948 0.1948 Columns 10 through 14 2.2727 4.5195 6.9351 9.5195 0.5844 wich is different to vect2!! Can you help me? thx
On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote:
> Hi, > > I have a problem with vector deconvolution. This is what I do in Matlab: > > > > >> vect1=[1 2 3 4 5 6 7 8 9]; > >> vect2=[1 2 3 4 0 0 0 0 0 0 0 0 0 0]; %I want to find w with > conv(w,vect1)=vect2 > >> Lx=length(vect2)-length(vect1)+1; > >> Lx2=pow2(nextpow2(Lx)); > >> VECT1=fft(vect1,Lx2); > >> VECT2=fft(vect2,Lx2); > >> W=VECT2 ./ VECT1; > >> w=real(ifft(W,Lx2)); > >> w=w(1:1:Lx); > >> w=w/max(abs(w)); > >> conv(w,vec1) give this result > > ans = > > Columns 1 through 9 > > -0.1688 -0.5065 -1.0130 -1.6883 -1.3636 -0.9740 -0.5844 -0.1948 0.1948 > > Columns 10 through 14 > > 2.2727 4.5195 6.9351 9.5195 0.5844 > > wich is different to vect2!! > > Can you help me? > > thx
The error is in truncating the length of w in the step: w=w(1:1:Lx); Once you truncate it to a smaller length, the expected convolution result need not hold.
>On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote:
This is the result I get when I don't truncate w: ans = Columns 1 through 9 -0.0903 -0.2708 -0.5417 -0.9028 -0.7292 -0.5208 -0.2778 -0.0000 0.2778 Columns 10 through 16 1.4583 2.7292 4.0903 5.5417 0.8333 0.5903 0.3125 which is also wrong!
On 24 Sep, 09:49, "sofiyya" <karimae...@gmail.com> wrote:
> >On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote: > > This is the result I get when I don't truncate w: > > ans = > > &#4294967295; Columns 1 through 9 > > &#4294967295; &#4294967295;-0.0903 &#4294967295; -0.2708 &#4294967295; -0.5417 &#4294967295; -0.9028 &#4294967295; -0.7292 &#4294967295; -0.5208 &#4294967295; -0.2778 &#4294967295; > -0.0000 &#4294967295; &#4294967295;0.2778 > > &#4294967295; Columns 10 through 16 > > &#4294967295; &#4294967295; 1.4583 &#4294967295; &#4294967295;2.7292 &#4294967295; &#4294967295;4.0903 &#4294967295; &#4294967295;5.5417 &#4294967295; &#4294967295;0.8333 &#4294967295; &#4294967295;0.5903 &#4294967295; &#4294967295;0.3125 > > which is also wrong!
Once again: Are you sure the problem as stated has a solution? Rune
On 24 Sep., 09:49, "sofiyya" <karimae...@gmail.com> wrote:
> >On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote: > > This is the result I get when I don't truncate w: > > ans = > > &#4294967295; Columns 1 through 9 > > &#4294967295; &#4294967295;-0.0903 &#4294967295; -0.2708 &#4294967295; -0.5417 &#4294967295; -0.9028 &#4294967295; -0.7292 &#4294967295; -0.5208 &#4294967295; -0.2778 &#4294967295; > -0.0000 &#4294967295; &#4294967295;0.2778 > > &#4294967295; Columns 10 through 16 > > &#4294967295; &#4294967295; 1.4583 &#4294967295; &#4294967295;2.7292 &#4294967295; &#4294967295;4.0903 &#4294967295; &#4294967295;5.5417 &#4294967295; &#4294967295;0.8333 &#4294967295; &#4294967295;0.5903 &#4294967295; &#4294967295;0.3125 > > which is also wrong!
Your method is flawed alltogehter. In general, w will have infinite length. Any truncation to use the FFT won't produce the expected results. w can be found through long division of v2 by v1. This is very simple to do with pencil and paper, the first couple of values in w are w = [1 0 0 0 -5 4 ...] Regards, Andor
On 24 Sep., 10:45, Andor <andor.bari...@gmail.com> wrote:
> On 24 Sep., 09:49, "sofiyya" <karimae...@gmail.com> wrote: > > > > > > > >On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote: > > > This is the result I get when I don't truncate w: > > > ans = > > > &#4294967295; Columns 1 through 9 > > > &#4294967295; &#4294967295;-0.0903 &#4294967295; -0.2708 &#4294967295; -0.5417 &#4294967295; -0.9028 &#4294967295; -0.7292 &#4294967295; -0.5208 &#4294967295; -0.2778 &#4294967295; > > -0.0000 &#4294967295; &#4294967295;0.2778 > > > &#4294967295; Columns 10 through 16 > > > &#4294967295; &#4294967295; 1.4583 &#4294967295; &#4294967295;2.7292 &#4294967295; &#4294967295;4.0903 &#4294967295; &#4294967295;5.5417 &#4294967295; &#4294967295;0.8333 &#4294967295; &#4294967295;0.5903 &#4294967295; &#4294967295;0.3125 > > > which is also wrong! > > Your method is flawed alltogehter. In general, w will have infinite > length. Any truncation to use the FFT won't produce the expected > results. w can be found through long division of v2 by v1. This is > very simple to do with pencil and paper, the first couple of values in > w are > > w = [1 0 0 0 -5 4 ...]
If you add 5 more terms yourself, I'll reveal the matlab one-liner that calculates w to arbitrary length :-).
>On 24 Sep, 09:49, "sofiyya" <karimae...@gmail.com> wrote: >> >On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote: >> >> This is the result I get when I don't truncate w: >> >> ans =3D >> >> =A0 Columns 1 through 9 >> >> =A0 =A0-0.0903 =A0 -0.2708 =A0 -0.5417 =A0 -0.9028 =A0 -0.7292 =A0
-0.520=
>8 =A0 -0.2778 =A0 >> -0.0000 =A0 =A00.2778 >> >> =A0 Columns 10 through 16 >> >> =A0 =A0 1.4583 =A0 =A02.7292 =A0 =A04.0903 =A0 =A05.5417 =A0 =A00.8333
=
>=A0 =A00.5903 =A0 =A00.3125 >> >> which is also wrong! > >Once again: Are you sure the problem as stated has a solution? > >Rune >
No, I'm not sure! But I didn't find explication for this! Maybe the deconvolution is not a stable solution...
Thank you for your response,

Yes, with pencil and paper we can calculate w but it will be difficult for
a long vector, that's why I look for a methods to do it with matlab.. Maybe
it's impossible or maybe this depends on the coefficients of vect1 or
vect2.. I guess that we can't always find w / conv(w,vect1)=vect2; 

>On 24 Sep., 10:45, Andor <andor.bari...@gmail.com> wrote: >> On 24 Sep., 09:49, "sofiyya" <karimae...@gmail.com> wrote: >> >> >> >> >> >> > >On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote: >> >> > This is the result I get when I don't truncate w: >> >> > ans =3D >> >> > =A0 Columns 1 through 9 >> >> > =A0 =A0-0.0903 =A0 -0.2708 =A0 -0.5417 =A0 -0.9028 =A0 -0.7292 =A0
-0.5=
>208 =A0 -0.2778 =A0 >> > -0.0000 =A0 =A00.2778 >> >> > =A0 Columns 10 through 16 >> >> > =A0 =A0 1.4583 =A0 =A02.7292 =A0 =A04.0903 =A0 =A05.5417 =A0
=A00.8333 =
>=A0 =A00.5903 =A0 =A00.3125 >> >> > which is also wrong! >> >> Your method is flawed alltogehter. In general, w will have infinite >> length. Any truncation to use the FFT won't produce the expected >> results. w can be found through long division of v2 by v1. This is >> very simple to do with pencil and paper, the first couple of values in >> w are >> >> w =3D [1 0 0 0 -5 4 ...] > >If you add 5 more terms yourself, I'll reveal the matlab one-liner >that calculates w to arbitrary length :-). >
As I said, if you calculate 5 more terms in the w that I started
below, I will tell you how to calculate w (given v1 and v2) in Matlab
with one single command that has only 28 characters (challenge: who
can do it in less?).

:-)


On 24 Sep., 14:27, "sofiyya" <karimae...@gmail.com> wrote:
> Thank you for your response, > > Yes, with pencil and paper we can calculate w but it will be difficult for > a long vector, that's why I look for a methods to do it with matlab.. Maybe > it's impossible or maybe this depends on the coefficients of vect1 or > vect2.. I guess that we can't always find w / conv(w,vect1)=vect2; > > > > > > >On 24 Sep., 10:45, Andor <andor.bari...@gmail.com> wrote: > >> On 24 Sep., 09:49, "sofiyya" <karimae...@gmail.com> wrote: > > >> > >On Sep 23, 7:25 am, "sofiyya" <karimae...@gmail.com> wrote: > > >> > This is the result I get when I don't truncate w: > > >> > ans =3D > > >> > =A0 Columns 1 through 9 > > >> > =A0 =A0-0.0903 =A0 -0.2708 =A0 -0.5417 =A0 -0.9028 =A0 -0.7292 =A0 > -0.5= > >208 =A0 -0.2778 =A0 > >> > -0.0000 =A0 =A00.2778 > > >> > =A0 Columns 10 through 16 > > >> > =A0 =A0 1.4583 =A0 =A02.7292 =A0 =A04.0903 =A0 =A05.5417 =A0 > =A00.8333 = > >=A0 =A00.5903 =A0 =A00.3125 > > >> > which is also wrong! > > >> Your method is flawed alltogehter. In general, w will have infinite > >> length. Any truncation to use the FFT won't produce the expected > >> results. w can be found through long division of v2 by v1. This is > >> very simple to do with pencil and paper, the first couple of values in > >> w are > > >> w =3D [1 0 0 0 -5 4 ...] > > >If you add 5 more terms yourself, I'll reveal the matlab one-liner > >that calculates w to arbitrary length :-).- Zitierten Text ausblenden - > > - Zitierten Text anzeigen -
On 24 Sep, 15:04, Andor <andor.bari...@gmail.com> wrote:
> As I said, if you calculate 5 more terms in the w that I started > below, I will tell you how to calculate w (given v1 and v2) in Matlab > with one single command that has only 28 characters (challenge: who > can do it in less?).
I can do it with a 1-character command: %%%%%%%%%% File a.m %%%%%%%%%%%%% % implement computations here %%%%%%%%% End of a.m %%%%%%%%%%%% in which case the one-liner becomes
>> a
But that might not have been what you mean...? Rune