北航物理实验1071数据处理

本文介绍了使用C++编写的程序,用于处理北航物理实验1071中分光仪的数据,包括自准直法、反射法、最小偏向角法和掠入射法测量三棱镜顶角和折射率,通过输入数据进行计算并输出误差分析。
摘要由CSDN通过智能技术生成
为了好处理数据,花了点时间写个几个小程序,做过实验思路还是挺容易懂的啦,注意一定要按照注释输入数据哦,或者根据数据的特点改一下条件语句也可以。

//自准直法测量三棱镜顶角 
#include <cstdio>
#include <algorithm>
using namespace std;

double deal(double a, double b, double c, double d){
	double x = a - c;
	double y = b - d;
	if(x < 0){
		x = -x;
	}
	else{
		x = 360 - x;
	}
	if(y < 0){
		y = -y;
	}
	else{
		y = 360 - y;
	}
	return 0.5 * (x + y);
}

int main()
{
	//输入有顺序的...保证a[1]-a[3] && a[2]-a[4]为-120或者240左右 
	while(true){
		double a[5][10], b[10], aver_b = 0;
		double x, y;
		for(int i=1; i<=4; i++){
			for(int j=1; j<=5; j++){
				scanf("%lf%lf", &x, &y);
				a[i][j] = x + y/60;
			}
		}
		for(int i=1; i<=5; i++){
			b[i] = deal(a[1][i], a[2][i], a[3][i], a[4][i]);
			printf("sita%d: %3.10lf\n", i, b[i]);
			aver_b += b[i];
		}
		aver_b /= 5;
		printf("average_sita: %3.10lf\n", aver_b);
		printf("A: %3.10lf\n", 180 - aver_b);
		double ua = 0, ub = 0, u = 0;
		for(int i=1; i<=5; i++){
			ua += (b[i] - aver_b) * (b[i] - aver_b);
		}
		ua = sqrt(ua/20);
		ub = 1.0/60/sqrt(3);
		printf("ua(sita): %3.10l
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值