### Tags: algorithm, code, converting, fixed, fixed-point, floating, havety, matlab, matrices, package, perfectly, point, pointinto, programming, troubles

# Troubles with fixed-point package and matrices

On Programmer » Matlab

3,278 words with 2 Comments; publish: Wed, 07 May 2008 23:08:00 GMT; (200109.38, « »)

I'm converting an algorithm that works perfectly in floating point

into fixed point. At one point in the fixed-point code, I have:

Ty = numerictype(true,16,15);

Tacc = numerictype(true,40,31);

Facc = fimath('RoundMode', 'floor', ...

'OverflowMode', 'saturate', ...

'ProductMode', 'SpecifyPrecision', ...

'ProductWordLength', 32, ...

'ProductFractionLength', 31, ...

'SumMode', 'SpecifyPrecision', ...

'SumWordLength', 40, ...

'SumFractionLength', 31, ...

'CastBeforeSum', 1);

k = 1;

accf = fi(acc(k,:)/(2^15),Ty,Facc);

simlogf.main.state = fi(zeros(8,nsamples),Ty,Facc);

simlogf.main.state(1,:) = accf(k,:);

Everything works until the last statement. The size of

simlogf.main.state is 8 X nsamples before the last statement (as it

should be), and 1 X nsamples after the last statement! acc is a

previously assigned matrix 4 X nsamples of values in the range 2^15

to -2^15+1.

Why is the fixed-point array changing into a fixed point row vector?

Scott Miller

to reply, takeout chinese food

*http://matlab.todaysummary.com/q_matlab_60795.html*

All Comments

Leave a comment...

- 2 Comments
- That should be
"accf (rather than acc) is a previously assigned matrix 4 X nsamples

of values in the range 2^15 to -2^15+1." Everything else is true,

and the problem still remains.

>

Scott Miller wrote:

>

> I'm converting an algorithm that works perfectly in floating point

> into fixed point. At one point in the fixed-point code, I have:

> Ty = numerictype(true,16,15);

> Tacc = numerictype(true,40,31);

> Facc = fimath('RoundMode', 'floor', ...

> 'OverflowMode', 'saturate', ...

> 'ProductMode', 'SpecifyPrecision', ...

> 'ProductWordLength', 32, ...

> 'ProductFractionLength', 31, ...

> 'SumMode', 'SpecifyPrecision', ...

> 'SumWordLength', 40, ...

> 'SumFractionLength', 31, ...

> 'CastBeforeSum', 1);

> k = 1;

> accf = fi(acc(k,:)/(2^15),Ty,Facc);

> simlogf.main.state = fi(zeros(8,nsamples),Ty,Facc);

> simlogf.main.state(1,:) = accf(k,:);

> Everything works until the last statement. The size of

> simlogf.main.state is 8 X nsamples before the last statement (as it

> should be), and 1 X nsamples after the last statement! acc is a

> previously assigned matrix 4 X nsamples of values in the range 2^15

> to -2^15+1.

> Why is the fixed-point array changing into a fixed point row

> vector?

> Scott Miller

> to reply, takeout chinese food

#1; Wed, 07 May 2008 23:09:00 GMT

- That should be
- Dang, I'm tired! The original post was correct; the problem still
exists.

Scott Miller wrote:

>

> That should be

> "accf (rather than acc) is a previously assigned matrix 4 X

> nsamples

> of values in the range 2^15 to -2^15+1." Everything else is true,

> and the problem still remains.

>

> Scott Miller wrote:

> point

have:

(as

> it

a

> 2^15

#2; Wed, 07 May 2008 23:10:00 GMT

- Dang, I'm tired! The original post was correct; the problem still