Error using dbscan. Expected X to be nonempty

2 ビュー (過去 30 日間)
Divya
Divya 2022 年 11 月 25 日
コメント済み: Divya 2022 年 11 月 25 日
I have written a code that converts phase differences to path differenes. There seems to be an error while using dbscan. How can I fix this error? Thanks for the help
This is my code :
lambda = 34.64; % in cm, considering 866MhZ frequency
pathData_1 = zeros(1,6);
for i=1:5
theta=PhData_1(i+1)-PhData_1(i);
thetaRad=pi*theta/180;
pathData_1(i)=(thetaRad)*lambda/(4*pi);
end
a=pathData_1/2;
c=ones(1,6).*4; % fixed 8cm distance between two antenna positions
b=sqrt(16-a.^2);
syms xp yp
origin = [4 12 0 8 6 4 2 0 8 76];
validpts=double.empty(0,3);
count=0;
for iter=1:6
ap=a(iter);
bp=b(iter);
if isreal(ap)&&isreal(bp)
count=count+1;
validpt=[origin(iter) ap bp];
validpts=[validpts; validpt];
end
end
figure('Name','For tag ID');
for iter=1:count
f_new = @(xp,yp) ((yp-validpts(iter,1))^2/(validpts(iter,2)^2))-((xp)^2/(validpts(iter,3)^2))-1;
hold on;
fimplicit(f_new)
xlim([-150 150]);
ylim([-50 100]);
end
interpts=double.empty(0,2);
for x=-150:0.1:0
for y=0:0.1:180
for i=1:count
for j=1:count
if abs((((y-validpts(i,1))^2/(validpts(i,2)^2))-((x)^2/(validpts(i,3)^2))-1))<0.001
if abs((((y-validpts(j,1))^2/(validpts(j,2)^2))-((x)^2/(validpts(j,3)^2))-1))<0.001
interpts=[interpts; [x y]];
end
end
end
end
end
end
hold on;
idx = dbscan(interpts,3,3);
gscatter(interpts(:,1),interpts(:,2),idx,'kr','*');

採用された回答

C B
C B 2022 年 11 月 25 日
編集済み: C B 2022 年 11 月 25 日
Error You are getting
Expected X to be nonempty
Because of variable
interpts
is empty.
and it is empty because it is never going either if statement.
if abs((((y-validpts(i,1))^2/(validpts(i,2)^2))-((x)^2/(validpts(i,3)^2))-1))<0.001
'First If check'
if abs((((y-validpts(j,1))^2/(validpts(j,2)^2))-((x)^2/(validpts(j,3)^2))-1))<0.001
'Second If check'
interpts=[interpts; [x y]];
end
end
You can try debugging why its not entering this if.
lambda = 34.64; % in cm, considering 866MhZ frequency
pathData_1 = zeros(1,6);
PhData_1 =zeros(1,6);
for i=1:5
theta=PhData_1(i+1)-PhData_1(i);
thetaRad=pi*theta/180;
pathData_1(i)=(thetaRad)*lambda/(4*pi);
end
a=pathData_1/2;
c=ones(1,6).*4; % fixed 8cm distance between two antenna positions
b=sqrt(16-a.^2);
syms xp yp
origin = [4 12 0 8 6 4 2 0 8 76];
validpts=double.empty(0,3);
count=0;
for iter=1:6
ap=a(iter);
bp=b(iter);
if isreal(ap)&&isreal(bp)
count=count+1;
validpt=[origin(iter) ap bp];
validpts=[validpts; validpt];
end
end
figure('Name','For tag ID');
for iter=1:count
f_new = @(xp,yp) ((yp-validpts(iter,1))^2/(validpts(iter,2)^2))-((xp)^2/(validpts(iter,3)^2))-1;
hold on;
fimplicit(f_new)
xlim([-150 150]);
ylim([-50 100]);
end
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
interpts=double.empty(0,2);
for x=-150:0.1:0
for y=0:0.1:180
for i=1:count
for j=1:count
if abs((((y-validpts(i,1))^2/(validpts(i,2)^2))-((x)^2/(validpts(i,3)^2))-1))<0.001
'First If check'
if abs((((y-validpts(j,1))^2/(validpts(j,2)^2))-((x)^2/(validpts(j,3)^2))-1))<0.001
'Second If check'
interpts=[interpts; [x y]];
end
end
end
end
end
end
hold on;
interpts
interpts = 0×2 empty double matrix
idx = dbscan(interpts,3,3);
Error using dbscan
Expected X to be nonempty.
gscatter(interpts(:,1),interpts(:,2),idx,'kr','*');
  1 件のコメント
Divya
Divya 2022 年 11 月 25 日
Okay, this helps. Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeParticle & Nuclear Physics についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by