matlab 间接平差法拟合二维圆

226 篇文章 3248 订阅 ¥19.90 ¥99.00
本文介绍了使用matlab进行二维圆的间接平差法拟合的算法原理,通过构建误差方程并转化为矩阵形式,然后利用等精度观测数据,依据间接平差原理求解圆心坐标和半径。文中还包含代码实现和结果展示。
摘要由CSDN通过智能技术生成
间接平差原理写的代码,绝对有用,真实可靠 Dim strFileName As String Dim nn%, un%, tn%, hn% '已知点个数,未知点个数,总点数,观测值个数 Dim Pname() As String '点名数组 Dim Hknown() As Double '已知高程数组,存放已知点高程和高程近似值 Dim be%(), en%() '观测值的起点和终点编号数组,存储的是点序号 Dim h#(), s#() '高差观测值数组和距离观测值数组 Dim A#(), X#(), P#(), L#() '间接平差的系数阵、解向量、权阵和常数向量 '平差计算 Private Sub mnuAdj_Click() Dim i%, j% ReDim X(1 To un) InAdjust A, P, L, X '调用间接平差的通用过程求解 '计算并显示高程平差结果 txtShow.Text = txtShow.Text & "平差计算结果:" & vbCrLf txtShow.Text = txtShow.Text & "点号 初始高程(m) 高程改正数(m) 平差后高程(m)" & vbCrLf For i = 1 To un txtShow.Text = txtShow.Text & Pname(nn + i) & " " & Format(Hknown(nn + i), "0.0000") Hknown(nn + i) = Hknown(nn + i) + X(i) txtShow.Text = txtShow.Text & " " & Format(X(i), "0.0000") & " " & Format(Hknown(nn + i), "0.0000") & vbCrLf Next i txtShow.Text = txtShow.Text & vbCrLf '计算并显示单位权中误差--------->>精度评定部分应该也包含在间接平差模块里,一起来调用 ' Dim dblT As Double ' dblT = 0 ' For i = 1 To un ' ' Next i End Sub '列立误差方程:给A、P、L赋值 Private Sub mnuEqu_Click() Dim i%, j% ReDim A(1 To hn, 1 To un), L(1 To hn), P(1 To hn, 1 To hn) '对每个观测值列误差方程 For i = 1 To hn If en(i) > nn Then A(i, en(i) - nn) = 1 '若终点未知,则给终点对应的系数矩阵元素赋值 If be(i) > nn Then A(i, be(i) - nn) = -1 '若起点未知,则给起点对应的系数矩阵元素赋值 L(i) = -(Hknown(en(i)) - Hknown(be(i)) - h(i)) '根据起终点计算常数项 P(i, i) = 1 / s(i) '以距离的倒数为权 Next i '显示误差方程 txtShow.Text = txtShow.Text & " 列立的误差方程:" & vbCrLf For i = 1 To hn For j = 1 To un txtShow.Text = txtShow.Text & A(i, j) & " " Next j txtShow.Text = txtShow.Text & " " & Format(L(i), "0.0000") & vbCrLf Next i txtShow.Text = txtShow.Text & "权矩阵:" & vbCrLf For i = 1 To hn For j = 1 To hn txtShow.Text = txtShow.Text & P(i, j) & " " Next j txtShow.Text = txtShow.Text & vbCrLf Next i End Sub '计算近似高程 Private Sub mnuHeight_Click() Dim i%, j% For i = 1 To un For j = 1 To hn If be(j) = nn + i And en(j) < nn + i Then '找到一个起点相同且终点已知的观测值 Hknown(nn + i) = Hknown(en(j)) - h(j) Exit For End If If en(j) = nn + i And be(j) < nn + i Then '找到一个终点相同且起点已知的观测值 Hknown(nn + i) = Hknown(be(j)) + h(j) Exit For End If Next j Next i '显示近似高程计算结果 txtShow.Text = txtShow.Text & " 近似高程计算结果: " & vbCrLf For i = 1 To un txtShow.Text = txtShow.Text & Pname(i + nn) & ":" & Format(Hknown(i + nn), "0.000") & vbCrLf Next i End Sub '退出程序 Private Sub mnuExit_Click() End End Sub '打开文件 Private Sub mnuOpen_Click() Dim i As Integer '循环变量 Dim strT1 As String, strT2 As String CDg1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" CDg1.ShowOpen '打开对话框 strFileName = CDg1.FileName '获得选中的文件名和路径 Open strFileName For Input As #1 '打开文件 Input #1, nn, un, hn '读入已知点个数,未知点个数,观测值个数 tn = nn + un ReDim Pname(1 To tn), Hknown(1 To tn) ReDim h(1 To hn), s(1 To hn), be(1 To hn), en(1 To hn) For i = 1 To tn '读入点名 Input #1, Pname(i) Next i For i = 1 To nn '读入已知高程 Input #1, Hknown(i) Next i For i = 1 To hn '读入各观测值 Input #1, strT1, strT2, h(i), s(i) be(i) = Order(strT1): en(i) = Order(strT2) '给起终点数组排序 Next i '显示读入的数据 txtShow.Text = txtShow.Text & "读入的水准网数据:" & vbCrLf txtShow.Text = txtShow.Text & " 已知点" & nn & "个,未知点" & un & "个,观测值" & hn & "个。" & vbCrLf txtShow.Text = txtShow.Text & " 网中涉及的点名有:" For i = 1 To tn txtShow.Text = txtShow.Text & Pname(i) & "," Next i txtShow.Text = txtShow.Text & vbCrLf txtShow.Text = txtShow.Text & " 已知点高程为:" & vbCrLf For i = 1 To nn txtShow.Text = txtShow.Text & Pname(i) & "的高程为:" & Hknown(i) & vbCrLf Next i txtShow.Text = txtShow.Text & " 各观测值分别为:" & vbCrLf txtShow.Text = txtShow.Text & "起点" & " " & "终点" & " " & "高差观测值 " & " 距离观测值" & vbCrLf For i = 1 To hn txtShow.Text = txtShow.Text & Pname(be(i)) & " " & Pname(en(i)) & " " & Format(h(i), "0.000") & " " & Format(s(i), "0.000") & vbCrLf Next i Close #1 '不要忘记关闭文件 End Sub '点名-序号转换函数 Public Function Order(str As String) As Integer Dim i% For i = 1 To tn If str = Pname(i) Then Order = i Exit For End If Next i End Function '保存计算结果 Private Sub mnuSave_Click() CDg1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" CDg1.ShowSave strFileName = CDg1.FileName Open strFileName For Output As #1 Print #1, txtShow.Text Close #1 End Sub
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

点云侠

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值