当前位置: 首页 > news >正文

无线传感器网络的时钟同步估计问题(Matlab代码实现)

👨‍🎓个人主页:研学社的博客    

💥💥💞💞欢迎来到本博客❤️❤️💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

📋📋📋本文目录如下:🎁🎁🎁

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

🌈4 Matlab代码实现


💥1 概述

随着无线传感器网络的快速发展,其应用领域也越来越广。在诸多的应用环境中都需要大量已同步的传感器节点通过协同作用执行一个分布式的任务,因此时钟同步成为了无线传感器网络众多应用的基础。​

📚2 运行结果

主函数部分代码:

% Code for Clock Synchronization for Wireless Sensor Networks
clc
clear all
close all
load("ClockSync.mat");
​
tx = tx_timestamps;
rx = rx_timestamps;
​
% Estimate of phi2 based on the Clock Synchronisation Equation
x = rx - tx - tau;
% (x has a Gaussian noise distribution (contributions from rx & tx measurement errors)
​
% Phi_2 Scaled as per Data set
phi_2s = phi_2 .* ones(K,trial,6);
phi2 = phi_2 .* ones(10,6);
p = phi_2.* ones(1,6);
​
% Estimated phi - Mean of timestamps of K messages with trials
phi_mean = squeeze(mean(x,2));
% Standard Deviation for K messages with trials
phi_std  = squeeze(std(x,1,2));
% Bias in Measurements for K messages with trials
phi_bias = (phi_mean - phi2).^2;
% Variance in Measurements for K messages
phi_var = (1/trial) * phi_std.^2;
​
% Calculated MSE & CRLB for the Dataset (average over K messages)
se = (x - phi_2s).^2 ;% Squared Error
mse_c = mean(squeeze(mean(se,2)));
crlb_c = mean(phi_var);
​
% Theoretical MSE & CRLB for the Dataset (average over K messages)
mse_t = mean(phi_var + phi_bias);
crlb_t = (1/trial) * noise_var;
​
% Phi : Estimates and Standard deviations
phi_mm = mean(phi_mean);
phi_sm = mean(phi_std);% Plot of Theoretical & Estimated CRLB vs. Noise Variance 
figure
loglog(noise_var, crlb_t,'Marker', 'o')
%hold on
%loglog(noise_var, crlb_c,'Marker', 'x')
title('CRLB of \phi with noise variance','FontName', 'Times')
xlabel('Noise \sigma^2','FontName', 'Times')
ylabel('CRLB','FontName', 'Times')
legend('Theoretical CRLB') %, 'Calculated CRLB')
saveas(gca,['CRLB_Variance.png']);
​
% Plot of MSE vs. Noise Variance 
figure
loglog(noise_var, mse_t,'Marker', 'o')
hold on
loglog(noise_var, mse_c,'Marker', 'x')
title('MSE of \phi with noise variance','FontName', 'Times')
xlabel('Noise \sigma^2','FontName', 'Times')
ylabel('MSE','FontName', 'Times')
legend('Theoretical MSE', 'Calculated MSE')
saveas(gca,['MSE_Variance.png']);
​
% Plot of Phi_Estimate vs. Noise Variance 
figure
semilogx(noise_var, p,'Marker','o')
hold on
semilogx(noise_var, phi_mm,'Marker', 'x')
title('Estimate of \phi with noise variance','FontName', 'Times')
xlabel('Noise \sigma^2','FontName', 'Times')
ylabel('Estimate E[\phi]','FontName', 'Times')
legend('Reference', 'Numerical Estimate')
saveas(gca,['Estimate_Variance.png']);
​
% Plot of Data Sets with different noise variances
min_x = min(x,[],'all');
max_x = max(x,[],'all');
figure('Renderer', 'painters', 'Position', [10 10 1200 600])
t = tiledlayout(2,3,'TileSpacing','none');
for i = 1 : 6nexttilex1 = x(:,:,i);grid minor% pdf distribution for plotting Observed Datax_pdf(i,:) = linspace(min_x,max_x,K*trial);y_pdf(i,:) = normpdf(x_pdf(i,:), phi_mm(i), phi_sm(i));xline(phi_mm(i),'-','Estimate');hold onhistogram(x1(:), 'Normalization', 'pdf', 'EdgeColor','k' ,'FaceColor' , 'none');hold onplot(x_pdf(i,:), y_pdf(i,:), 'color', 'b' , 'LineWidth',1);title(['E[\phi] for 10k MC run; Noise \sigma^2  = ', num2str(phi_sm(i))],'FontName', 'Times');xlabel('Distribution','FontName', 'Times');ylabel(['PDF'],'FontName', 'Times');
end

🎉3 参考文献

[1]田贤忠,龚婷,胡同森.基于指数时延的无线传感器网络时钟同步估计[J].小型微型计算机系统,2009,30(11):2186-2188.

部分理论引用网络文献,若有侵权联系博主删除。

🌈4 Matlab代码实现

http://www.xdnf.cn/news/812485.html

相关文章:

  • 论坛集
  • 10本java书籍,每一本都是经典,从菜鸡到大神
  • 全类别通用!提升11%!CAReg:超越FSAD实现少样本异常检测!
  • 科大讯飞和neospeech tts哪个更好
  • Win7系统提示找不到sethc.exe文件的解决办法
  • 2022 Typecho PureLove简单纯净主题
  • java证书验证失败_java – 如何解决“证书无效且无法用于验证此网站的身份”错误?...
  • WPF入门教程系列七——布局之WrapPanel与StackPanel(二)
  • 安卓广播使用时的ANR问题,onReceive的生命周期为10秒
  • windows安装npm教程
  • power supply是如何上报电池信息的
  • 信息学奥赛需要储备的数学知识有哪些?
  • 计算机专业都要学哪些课程?(非常详细)零基础入门到精通,收藏这一篇就够了(1)
  • Alpha-Blending 技术简介
  • 分享136个PHP源码,总有一款适合您
  • hh.exe的另类用法
  • 谈谈新库requests-html以及python爬虫 requests
  • 多路径 I/O
  • extensionloaded php,PHP函数extension_loaded()用法实例,extensionloaded_PHP教程
  • 磁盘分区全解:快速搞定硬盘分区
  • 2024年,值得收藏!推荐一些好用的数据库管理工具合集!
  • 2023年程序员必须知道的10大代码网站!
  • Red Hat Linux iso镜像文件(3)个
  • MATLAB—取整函数汇总(floor、round、ceil、fix)
  • 《软件安装与使用教程》— 最新Acrobat 8专业版Windows安装详细教程
  • EL表达式知识
  • 干货!12个程序员证书​,含金量超高
  • abab 模型进展|MiniMax 发布万亿 MoE 模型abab 6.5
  • ArrayAdapter 支持单选
  • AutoIT的下载与安装