i am getting error in this code like "Subscripted assignment dimension mismatch". please tell how to solve it
古いコメントを表示
tic
clc;
r=input('enter the cell radius in meters=');
N=input('enter the no of cells=');
S=3;
x(1)=1;
y(1)=1;
p(1,:)=[x(1),y(1)];
x=zeros(N,2);
y=zeros(N,2);
h=zeros(N,2);
P=zeros(N,1);
for i=2:N
x(i)=(i-1)*1.5*r;
h(i)=(i-1)*sqrt(3)*r;
y(i)=h(i)^2-x(i)^2;
p(i,:)=[x(i),y(i)];
end
for i=1:S
k=randint(1,1,[1 N]);
P(i,:)=p(k,:);
end
disp(P)
%finding the received signal strength captured by all sensor nodes
theta=2*pi*rand;
X=r*cos(theta);
Y=r*sin(theta);
M=[X,Y];
sum=0;
d=zeros(1,100);
for i=1:S
for j=1:2
a=sum+(M(1,j)-P(i,j))^2;
end
d(i)=sqrt(a);
end
d0=10;
n=4;
MRSS=-10*n*log(d0);
RSS=zeros(1,100);
t=zeros(100,100);
for i=1:S
RSS(i)=(MRSS-10*n*log(d(i)/d0))/5;
end
%finding stongest rssi and generating mapping circle
for i=1:S
d(i)=d0*10^((MRSS-RSS(i))/(10*n));
end
for i=1:S
for j=1:2
t(i,j)=(d(i))^2+M(1,j);
end
end
[v p]=min(d);
xth =x(p)+d(p)*cos(theta);
yth=y(p)+d(p)*sin(theta);
D(1,:)=[x(p)+d(p)*cos(theta),y(p)+d(p)*sin(theta)];
figure,
plot(t(1:3,1),t(1:3,2),'rs','MarkerEdgeColor','k',...
'MarkerFaceColor','g',...
'MarkerSize',4)
grid on
hold on
xlabel('x co-ordinate of sensor nodes')
ylabel('y co-ordinates of sensor nodes')
legend
plot(D(1,1),D(1,2),'bs','MarkerEdgeColor','k',...
'MarkerFaceColor','r',...
'MarkerSize',4)
%results
fprintf('RSSIs collected from 3 sensor nodes=')
disp(RSS)
fprintf('distance of mobile user from all 3 sensor nodes=')
disp(d)
fprintf('co-ordinates of the new location of the mobile user are=')
disp(D)
toc
1 件のコメント
Stephen23
2015 年 9 月 1 日
You use nonstandard function randint. The function randint is being obsoleted, and should be replaced with randi.
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!