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
fixed point response of convolution
Started by ●May 29, 2008
Reply by ●May 29, 20082008-05-29
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
Reply by ●May 30, 20082008-05-30
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�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
Reply by ●May 31, 20082008-05-31
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
Reply by ●June 2, 20082008-06-02
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
Reply by ●June 2, 20082008-06-02
>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, >fazOK, 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