线性差值算法

 

线性差值算法

 

 

 点斜式:

线性差值算法

 

 

 线性差值算法

 

 

#include<stdio.h>
#define N 10
float w = 10.0;
float w0 = 0.0;
float wn = 100.0;
int adc[N+1] = {86,376,687,1021,1379,1760,2164,2592,3043,3515,4008};
float line(int x)
{
     int i;
     if(x<adc[0]) return(w0);
     if(x>=adc[N]) return(wn);
     for(i=0;i<N;i++) if(x<adc[i+1]) break;
     return (w*i + (w*(x-adc[i])/(adc[i+1]-adc[i])));
}
main()
{
    int x;
    float y;
    while(1){
        printf("\n输入A/D转换结果");
        scanf("%d",&x);
        if(x==0)  break;
        y = line(x);
        printf("\n对应温度为:%2.2f度",y);
    }
}

相关文章:

  • 2021-12-06
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-06
  • 2021-12-29
猜你喜欢
  • 2022-12-23
  • 2021-12-08
  • 2021-09-24
  • 2021-06-30
  • 2022-12-23
  • 2021-10-28
相关资源
相似解决方案