DSPRelated.com
Forums

fixed point response of convolution

Started by faz May 29, 2008
Hai,

I have to write the response of convolution to a file as fixed point
arithmetic values but the following MATLAB code generate floating
point arithmetic.How to get fixed point arithmetic?

h=[-0.01711328125
 0.016012451171875
-0.030242919921875
 0.046417236328125];
Inp = zeros(300,1);
 Inp(1)=1;
 output = conv(h, Inp);

 outfile1 = fopen('imp_in.txt','w');
	fprintf(outfile1, '%d\n', Inp);
   fclose(outfile1);
   outfile1 = fopen('m_Inpulse_out.txt','w');
	fprintf(outfile1, '%d\n', output);
   fclose(outfile1);

regards,
faz
On 29 Mai, 16:52, faz <fazulu.v...@gmail.com> wrote:
> Hai, > > I have to write the response of convolution to a file as fixed point > arithmetic values but the following MATLAB code generate floating > point arithmetic.How to get fixed point arithmetic?
Try the command 'doc int16' (without the apostrophes) in matlab. Rune
Hai,


output = conv(h, Inp);

Using the above command the o/p was given as -1.611328e-002 but i need
to represent as -0.01611328125 fixed point arithemetic...wat change i
should do in MATLAB code


regards,
faz



On May 29, 8:57&#4294967295;pm, Rune Allnor <all...@tele.ntnu.no> wrote:
> On 29 Mai, 16:52, faz <fazulu.v...@gmail.com> wrote: > > > Hai, > > > I have to write the response of convolution to a file as fixed point > > arithmetic values but the following MATLAB code generate floating > > point arithmetic.How to get fixed point arithmetic? > > Try the command 'doc int16' (without the apostrophes) in matlab. > > Rune
I would check mathworks helpdesk.
There is a lot of excellent examples.
You can find almost every answer there if it comes to matlab.
http://www.mathworks.com/access/helpdesk/help/techdoc/index.html

I would also suggest to write to a matlab newsgroup
comp.soft-sys.matlab.

Your answer is "f" by the way.

-- 
Mikolaj
You might want to have a look at the Matlab fixed point toolbox.
At the matlab prompt type "ver" to find out if the fixed point toolbox
is installed.
Also can try "help fi"

Cheers
Andrew
>Hai, > > >output =3D conv(h, Inp); > >Using the above command the o/p was given as -1.611328e-002 but i need >to represent as -0.01611328125 fixed point arithemetic...wat change i >should do in MATLAB code > > >regards, >faz
OK, some terminology is being confused. He's not looking for integer math, but a format issue with the way MATLAB displays its answers. Simply setting your format to long, i.e. enter format long in your command window, should do the trick if all of your results are sized similarly. With this format, however, once one of the exponentials (in your array) gets over +/-4 (as far as I can tell), it will scale the results such all the data in the array is multiplied by the scale factor, though it will still be adjusted so each element shares the same "fixed point." Mark