| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 813 人关注过本帖
标题:重写 function low-pass filter
只看楼主 加入收藏
yuchao130
Rank: 2
等 级:论坛游民
帖 子:20
专家分:32
注 册:2014-2-19
结帖率:80%
收藏
已结贴  问题点数:50 回复次数:5 
重写 function low-pass filter
Applies a low-pass filter to sequences of valid temperature readings for consecutive times.
 * If a non-valid temperature reading is found, the filter should restart at the next valid
 * temperature reading. The following describes the low-pass filter used:
 *
 *    filtered_output(0) = unfiltered_input(0)
 *    filtered_output(n) = 0.9375 * filtered_output(n-1) + 0.0625 * unfiltered_input(n)
 *
 */
void LowPassFilter(ACTempData acTemps[])
{
    int a; // The first valid data.
    int i;
    int n;
    a = 0;
    i = 0;
    n = 1;
    while(acTemps[a].valid != 1)
        ++a;
    for(i = a; i < MinPerDay; ++i){
        n = 1;
        while(i != a && acTemps[i-n].valid == 0)
            ++n;
        if(i != a && acTemps[i].valid == 1){
            acTemps[i].temperature = 0.9375 * acTemps[i-n].temperature + 0.0625 * acTemps[i].temperature;
        }
    }
}
我实在没有办法了,只能求助论坛了。如何用另一种形势,比如改while 等等来重写这个function

[ 本帖最后由 yuchao130 于 2014-9-12 03:03 编辑 ]
搜索更多相关主题的帖子: filter reading function following describes 
2014-09-11 19:29
枫__________
Rank: 2
等 级:论坛游民
帖 子:11
专家分:29
注 册:2011-5-21
收藏
得分:17 
filtered_output(n) = 0.9375 * filtered_output(n-1) + 0.0625 * unfiltered_input(n)
怎么又是
acTemps[i].temperature = 0.9375 * acTemps[i-n].temperature + 0.0625 * acTemps[i].temperature;
看不懂

膜拜
2014-09-11 19:52
erty1001
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:4
帖 子:331
专家分:1433
注 册:2014-8-31
收藏
得分:17 
简单说说:
acTemps[i].temperature = 0.9375 * acTemps[i-n].temperature + 0.0625 * acTemps[i].temperature;?
这个实现不了 就像要求a
a不知道是多少,但是a=5+a?
你说a是多少
2014-09-11 20:03
yuchao130
Rank: 2
等 级:论坛游民
帖 子:20
专家分:32
注 册:2014-2-19
收藏
得分:0 
回复 2 楼 枫 __________
我弄错了,我这个function弄明白了一部分。
2014-09-12 03:03
yuchao130
Rank: 2
等 级:论坛游民
帖 子:20
专家分:32
注 册:2014-2-19
收藏
得分:0 
回复 3 楼 erty1001
我只列出了整个程序的其中一个function,所以根本说不通。。。。。。。
2014-09-12 03:05
tlliqi
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:204
帖 子:15453
专家分:65956
注 册:2006-4-27
收藏
得分:17 
只列出了整个程序的其中一个function?
2014-09-12 07:46
快速回复:重写 function low-pass filter
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016940 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved