DSPRelated.com
Forums

Help in Fixed point toolbox for converting float to fixed

Started by Unknown February 17, 2005
i,

I have two floating point arrays say

Signal1 = sin(2 * pi * 10 * (.1:.1:10));
Signal2 = sin(2 * pi * 5 * (.1:.1:10));

Now I want to convolve those two signals after fixed point conversion

So FixedSignal1 = fi(Signal1,1,16);
   FixedSignal2 = fi(Signal2,1,16);
Output = conv(FixedSignal1,FixedSignal2);
The above statement is giving an error

?? Error using ==> conv
A and B must be vectors.

Can anyone help me in this regard??

Raj

Raj,

The function conv() is not defined for fixed point datatypes (fi's)  in 
MATLAB. However since you can do + & * with fi's you could infact implement 
your own convolution function that accepts fixed point values.

Thank you.

Ashok Charry
The Mathworks.

<bandaru.rajsekhar@gmail.com> wrote in message 
news:1108647540.919069.152710@z14g2000cwz.googlegroups.com...
> i, > > I have two floating point arrays say > > Signal1 = sin(2 * pi * 10 * (.1:.1:10)); > Signal2 = sin(2 * pi * 5 * (.1:.1:10)); > > Now I want to convolve those two signals after fixed point conversion > > So FixedSignal1 = fi(Signal1,1,16); > FixedSignal2 = fi(Signal2,1,16); > Output = conv(FixedSignal1,FixedSignal2); > The above statement is giving an error > > ?? Error using ==> conv > A and B must be vectors. > > Can anyone help me in this regard?? > > Raj >
Raj,

I forgot to metion that if you have the Filter Design toolbox you could also 
use the Discrete-time filter object (dfilt) to filter one of your signals 
using the other one as your coefficients:

Signal1 = sin(2 * pi * 10 * (.1:.1:10));
Signal2 = sin(2 * pi * 5 * (.1:.1:10));
FixedSignal1 = fi(Signal1,1,16);
FixedSignal2 = fi(Signal2,1,16);

% Use FixedSignal1 as your coefficients and FixedSignal2 as your input.
% Since the conv length is going to be 199 samples (100+100-1) zeropad the 
input

FixedSignal2(199) = 0;

% Set up your filter
H = dfilt.dffir; H.Arithmetic = 'fixed';
H.Numerator = FixedSignal1;
% Set the input word length to that of FixedSignal2's
H.InputFracLength =FixedSignal2.FractionLength;
output = filter(H,FixedSignal2);

Hope this helps.

Thanks,

Ashok Charry



"Ashok Charry" <acharry@mathworks.com> wrote in message 
news:cv2991$jrj$1@fred.mathworks.com...
> Raj, > > The function conv() is not defined for fixed point datatypes (fi's) in > MATLAB. However since you can do + & * with fi's you could infact > implement your own convolution function that accepts fixed point values. > > Thank you. > > Ashok Charry > The Mathworks. > > <bandaru.rajsekhar@gmail.com> wrote in message > news:1108647540.919069.152710@z14g2000cwz.googlegroups.com... >> i, >> >> I have two floating point arrays say >> >> Signal1 = sin(2 * pi * 10 * (.1:.1:10)); >> Signal2 = sin(2 * pi * 5 * (.1:.1:10)); >> >> Now I want to convolve those two signals after fixed point conversion >> >> So FixedSignal1 = fi(Signal1,1,16); >> FixedSignal2 = fi(Signal2,1,16); >> Output = conv(FixedSignal1,FixedSignal2); >> The above statement is giving an error >> >> ?? Error using ==> conv >> A and B must be vectors. >> >> Can anyone help me in this regard?? >> >> Raj >> > >
bandaru.rajsekhar@gmail.com wrote:
> i, > > I have two floating point arrays say > > Signal1 = sin(2 * pi * 10 * (.1:.1:10)); > Signal2 = sin(2 * pi * 5 * (.1:.1:10)); > > Now I want to convolve those two signals after fixed point conversion > > So FixedSignal1 = fi(Signal1,1,16); > FixedSignal2 = fi(Signal2,1,16); > Output = conv(FixedSignal1,FixedSignal2); > The above statement is giving an error > > ?? Error using ==> conv > A and B must be vectors. > > Can anyone help me in this regard?? > > Raj
What language? Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
"Jerry Avins" <jya@ieee.org> wrote in message 
news:jeWdnZEid5BvJYnfRVn-2g@rcn.net...
> What language?
MATLAB! Fixed-point programming in MATLAB.
> > Jerry > -- > Engineering is the art of making what you want from things you can get. > &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;
Ashok Charry wrote:
> "Jerry Avins" <jya@ieee.org> wrote in message > news:jeWdnZEid5BvJYnfRVn-2g@rcn.net... > >>What language? > > > MATLAB! Fixed-point programming in MATLAB.
There's a Matlab newsgroup where you can get answers from their staff. Jerry -- Engineering is the art of making what you want from things you can get. &#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;&#4294967295;