Path: news.mathworks.com!not-for-mail
From: "Michael Hui" <myhui@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: FPT : how to inherit an fi object's attributes
Date: Fri, 15 Aug 2008 19:49:01 +0000 (UTC)
Organization: Broadcom Corp
Lines: 40
Message-ID: <g84mjd$hpd$1@fred.mathworks.com>
Reply-To: "Michael Hui" <myhui@yahoo.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1218829741 18221 172.30.248.35 (15 Aug 2008 19:49:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 15 Aug 2008 19:49:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1388863
Xref: news.mathworks.com comp.soft-sys.matlab:485745



In my MATLAB workspace I do this:

cordic_p.addr_size   = 4;

cordic_p.out_size    = 23;

cordic_p.phase_size  = pow2(cordic_p.addr_size);

cordic_p.phdiff_size = cordic_p.phint_size -
cordic_p.phase_size;

phase_size_int = cordic_p.phase_size - 2; % The RTL only
does phase_size - 2 iterations, so we match it here

% Generate atan() ROM values
atan_quantized = fi ( atan(pow2(0:-1:-phase_size_int+1))/pi, ...
    'Signed', 0, 'WordLength', cordic_p.out_size-2,
'FractionLength', cordic_p.out_size-2, 'OverflowMode',
'saturate', 'RoundMode', 'round');


And then I pass atan_quantized to a function as a read-only
argument.

I want to create an fi object inside the function that
inherits almost all attributes of that argument, except I
want to increase its word length.

What is the proper way to do this?

I can do it like this inside the function, which is very
tedious:

aq = fi(zeros(size(atan_quantized)),...
   atan_quantized.fimath,...
   atan_quantized.numerictype,...
   'WordLength',atan_quantized.numerictype.WordLength+2,...
  
'FractionLength',atan_quantized.numerictype.FractionLength+2);