资源简介
包含质心定位 四边测距定位 加权四边测距定位算法,matlab编写,并比较这几种方法的定位误差

代码片段和文件信息
#include
#include
#include
#include
#define RSSI0 -58.13
#define Y 2.07
#define X 0.0
#define NMIN 4
#define NMAX 6
// 定义iBeacon节点
typedef struct
{
int num; // 节点编号
double x y; // iBeacon节点坐标
double rssi; // 用户接收的信号强度值
double d; // 到用户距离
} Beacon;
// 定义用户节点
typedef struct
{
double d; // 平均距离
double x y; // 用户坐标
} User;
// 计算二元一次方程解
bool calcM2x3(const double m[][3] double *x double *y)
{
double d = m[0][0]*m[1][1] - m[0][1]*m[1][0];
if(fabs(d) < 0.001)
return false;
double dx = m[0][2]*m[1][1] - m[0][1]*m[1][2];
double dy = m[0][0]*m[1][2] - m[0][2]*m[1][0];
*x = dx / d;
*y = dy / d;
return (*x < 0.0 || *y < 0.0) ? false : true;
}
// 计算用户节点位置
bool calcPosition(Beacon *node User *u int i1 int i2 int i3)
{
double m[3][3] = {
{
2* (node[i2].x - node[i1].x)
2* (node[i2].y - node[i1].y)
pow(node[i1].d 2.0) - pow(node[i2].d 2.0) -
pow(node[i1].x 2.0) + pow(node[i2].x 2.0) -
pow(node[i1].y 2.0) + pow(node[i2].y 2.0)
}
{
2* (node[i3].x - node[i2].x)
2* (node[i3].y - node[i2].y)
pow(node[i2].d 2.0) - pow(node[i3].d 2.0) -
pow(node[i2].x 2.0) + pow(node[i3].x 2.0) -
pow(node[i2].y 2.0) + pow(node[i3].y 2.0)
}
{
2* (node[i3].x - node[i1].x)
2* (node[i3].y - node[i1].y)
pow(node[i1].d 2.0) - pow(node[i3].d 2.0) -
pow(node[i1].x 2.0) + pow(node[i3].x 2.0) -
pow(node[i1].y 2.0) + pow(node[i3].y 2.0)
}
};
double m1[2][3] = {
m[0][0] m[0][1] m[0][2]
m[1][0] m[1][1] m[1][2]
};
double m2[2][3] = {
m[0][0] m[0][1] m[0][2]
m[2][0] m[2][1] m[2][2]
};
double m3[2][3] = {
m[1][0] m[1][1] m[1][2]
m[2][0] m[2][1] m[2][2]
};
double w[NMIN] = {
1.0/node[i1].d
1.0/node[i2].d
1.0/node[i3].d
1.0/node[i1].d + 1.0/node[i2].d + 1.0/node[i3].d
};
u->d = (node[i1].d*w[0] + node[i2].d*w[1] + node[i3].d*w[2]) / w[NMIN];
if (calcM2x3(m1 &u->x &u->y) == true)
return true;
else if(calcM2x3(m2 &u->x &u->y) == true)
return true;
else if(calcM2x3(m3 &u->x &u->y) == true)
return true;
return false;
}
// 快速排序规则
int inc(const void *a const void *b)
{
double diff = (*(Beacon *)a).d - (*(Beacon *)b).d;
if (diff < 0 && fabs(diff) > 0.001)
return -1;
else if(diff > 0 && fabs(diff) > 0.001)
return 1;
else
return 0;
}
int main(void)
{
Beacon node[NMAX] = {
{ 1 0.0 0.0 -64 2.28 }
{ 2 2.1 0.0 -62 0.90 }
{ 3 4.2 0.0 -71 2.28 }
{ 4 0.0 1.8 -65 2.28 }
{ 5 2.1 1.8 -71 0.90 }
{ 6 4.2 1.8 -6
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\
文件 147 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\.editorconfig
文件 5118 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\main.c
目录 0 2020-03-18 22:46 rssiPosition-master\rssiPosition-master\MATLAB\
文件 1721 2020-03-18 22:46 rssiPosition-master\rssiPosition-master\MATLAB\Barycenter.m
文件 766 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\Quadrilateral.m
文件 3693 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\Simulation.asv
文件 3063 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\Simulation.m
文件 2524 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\Simulation2.asv
文件 2758 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\Simulation2.m
文件 475 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\TestValue.m
文件 765 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\Trilateral.m
文件 207 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\Unti
文件 1016 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\MATLAB\WeightedQuadrilateral.m
文件 84 2020-03-18 22:51 rssiPosition-master\rssiPosition-master\MATLAB\新建文本文档.txt
文件 345 2019-04-12 17:08 rssiPosition-master\rssiPosition-master\README.md
- 上一篇:Huffman编解码算法及matlab实现
- 下一篇:变异系数法计算权重
相关资源
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
- k近邻算法matlab实现
评论
共有 条评论