同济大学物理实验数据处理- 集成霍尔传感器

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    double Us[] = { 2.500,2.489,2.477,2.465,2.454,2.443,2.432,2.421,2.409,2.398,2.387 };

    double U1[31] =
    { 5.4,10.4,21.7,41.6,65.9,78.7,84.4,87.0,88.2,89.1,89.6,89.9,90.2,90.4,90.5,90.6,
        90.6,90.6,90.5,90.5,90.4,90.3,89.9,89.3,88.6,87.5,85.2,80.7,70.3,50.0,24.0 };
    double U2[31] =
    { 8.0,11.7,23.5,44.2,69.4,81.0,86.4,88.7,90.0,90.9,91.3,91.7,91.9,92.0,92.1,92.2,
        92.3,92.3,92.2,92.2,92.0,91.9,91.6,91.0,90.1,88.9,86.5,82.2,72.4,50.4,26 };

    double pro_dif[5] = { 0 };
    const double pi = 3.1415926;
    double u0 = 4 * pi*(1e-7), Im = 200, L = 26, D = 3.5, N = 3000;
    double Ks, Bc;
    Bc = (u0*N*Im) / sqrt(D*D + L*L)*50;
    cout <<"理论磁感应强度:"<< setw(10) << setprecision(7) << Bc << endl;
    int i;
    for (i = 0;i < 5;i++)
    {
        pro_dif[i] = (Us[i + 1] - Us[i + 6]) / 125;
        cout << "" << i + 1 << "个逐差数据:" << setw(15) << setprecision(15) << pro_dif[i] << endl;
    }
    for (i = 1;i < 5;i++)
        pro_dif[0] += pro_dif[i];
    Ks = 31.67;
    cout << "Ks=" << Ks << endl;
    for (i = 0;i < 31;i++)
    {
        cout << "" << setw(2)<<i << "组:";
        cout << "平均值:" <<setw(6)<< (U1[i] + U2[i]) / 2 << "   B:" <<setw(6)<<setprecision(4)<< (U1[i] + U2[i]) / 2 / Ks << endl;
    }
}

修改一下数值即可使用

posted @ 2016-05-09 16:43  liutianchen  阅读(1112)  评论(0编辑  收藏  举报