from
Grey prediction algorithm for mobile user localization
by Bachan P
Algorithm predicts the received signal strength for the mobile user
|
| Grey_predition_algorithm.m |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% GREY PREDICTION ALGORITHM %
% for lOCALIZATION %
% of MOBILE USER %
% By %
% P.Bachan %
% NIT Kurukshetra %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tic
clc
clear all
clf
d0=rand;
n=4;
s=300;
w1=0.5;w2=0.5
mrss=-10*n*log10(d0);
a=0.5;b=6;
d=a+(b-a)*rand(1,s);
d=sort(d);
for i=1:s
RSS_0(i)=mrss-10*n*log10(d(i)/d0)-20;
end
for i=1:s
rss_0(i)=10^(-RSS_0(i)/10);
end
sum=0;
for i=1:s
sum=sum+rss_0(i);
rss_1(i)=sum;
end
for i=1:s-1
B(i,1)=-1/2.*(rss_1(i)+rss_1(i+1));
end
B(:,2)=1;
yn=(rss_0(2:s))';
v=inv(B'*B)*B'*yn;
a=v(1);
b=v(2);
for i=1:s
prss_1(i)=rss_1(i);
prss_1(i+1)=(rss_0(i)-b/a)*exp(-a*s)+(b/a);
prss_0(i)=rss_0(i);
prss_0(i+1)=prss_1(i+1)-prss_1(i);
end
PRSS_0(1:s)=-10*log10(prss_0(2:s+1));
for i=1:s
prss_2(i)=w1*rss_0(i)+w2*prss_0(i+1);
end
PRSS_2=-10*log10(prss_2);
%results and plots
fprintf('observed and predicted values of the RSSIs in dB are %g\n')
disp([RSS_0' PRSS_0' PRSS_2'])
rs_0(1:s)=awgn(RSS_0(1:s),d0-10);
prs_0(1:s)=awgn(PRSS_0(1:s),d0-10);
prs_2=awgn(PRSS_2,d0-10);
plot(d(1:s),rs_0(1:s),d(1:s),prs_0(1:s))
xlabel('distance in meters')
ylabel('signal strength in dB')
legend('Original RSSI','Predicted RSSI')
grid on
figure
plot(d(1:s),rs_0(1:s),d(1:s),prs_2(1:s))
xlabel('distance in meters')
ylabel('signal strength in dB')
legend('Original RSSI','Weight Predicted RSSI')
grid on
toc
|
|
Contact us at files@mathworks.com