我正在尝试缩放matlab生成的FIR系数。我找到了以下示例,但我无法从示例中找出缩放因子
b = 0.0080 0.2176 0.5488 0.2176 0.0080
>> [bsc, scfac]=fscale(b, bits)
bsc = 479 12989 32767 12989 479
scfac = 5.9702e+04
b 表示系数, fscale 是用于缩放系数的一些自定义函数,它需要 b 和位的数量(在这种情况下为16)并输出缩放系数 bsc 和比例因子 scfac ,FIR滤波器需要在FPGA上实现。我想弄清楚如何计算比例因子。
答案 0 :(得分:1)
您要求整数系数的16位表示。显然它是16位签名。所以,他们的范围是:
[-2^15..2^15-1] = [-32768..32767]
作为您的最大初始系数,绝对值为c ~= 0.5488
且为正,缩放系数为:
c * scfac = 2^15-1 = 32767
scfac = 32767 / c ~= 32767 / 0.5488 ~= 5.9702e+04
QED。
请注意,因为您的实际值是由Matlab打印的,只有小数点后的4位数,Matlab计算的scfac
与使用32767 / 0.5488
计算的值~ 59707
略有不同(<?php
$stmt = $db->stmt_init();
/* publish store for icube*/
$stmt->prepare( "SELECT id,offer_id,name,net_provider,date,visible,apikey,networkid FROM " ."affilate_offer_findall_icube WHERE visible='1' ");
$stmt->execute();
mysqli_stmt_execute($stmt); // <--------- currently missing!!!
mysqli_stmt_store_result($stmt);
$rows = mysqli_stmt_num_rows($stmt);
$stmt->bind_result( $id, $offer_id, $name, $net_provider, $date, $visible,$apikey,$networkid);
$sql = array();
if($rows>0)
{
while($info = $stmt->fetch() ) {
$jsondataicube = file_get_contents('filename/json?NetworkId='.$networkid.'&Target=Affiliate_Offer&Method=getThumbnail&api_key='.$apikey.'&ids%5B%5D='.$offer_id.'');
$dataicube = json_decode($jsondataicube, true);
foreach($dataicube['response']['data'][0]['Thumbnail'] as $key=>$val)
{
$offer_id = $dataicube['response']['data'][0]['Thumbnail']["$key"]['offer_id'];
$display = $dataicube['response']['data'][0]['Thumbnail']["$key"]['display'];
$filename = $dataicube['response']['data'][0]['Thumbnail']["$key"]['filename'];
$url = $dataicube['response']['data'][0]['Thumbnail']["$key"]['url'];
$thumbnail = $dataicube['response']['data'][0]['Thumbnail']["$key"]['thumbnail'];
$_filename = mysqli_real_escape_string($db,$filename);
$_url = mysqli_real_escape_string($db,$url);
$_thumbnail = mysqli_real_escape_string($db,$thumbnail);
$sql[] = '("'.$offer_id.'","icube","'.$_thumbnail.'","'.$_url.'")';
}
}
)。如果你要求Matlab打印更多数字,你会很快发现真正的值是59702.xxxxxx ...
另请注意,您的问题很少与FPGA有关。