Effacer les filtres
Effacer les filtres

Index exceeds the number of array elements. Index must not exceed 8.

1 vue (au cours des 30 derniers jours)
Prapthi
Prapthi le 3 Fév 2023
Réponse apportée : Swaraj le 10 Fév 2023
function [dets_cluster] = clustering(dets,N_vfft,veloc_bin_norm,dis_thrs,rng_grid,agl_grid)
dets_cluster = [];
dets_num = size(dets, 1);
flag = zeros(1, dets_num); % for clusterng
[~, I] = sort(dets(:,4), 'descend');
for idx = 1:dets_num
% check the flag of current elemnt, if 1, skip comparing
if flag(I(idx))
continue
end
range_bin = dets(I(idx), 1);
veloc_bin = dets(I(idx), 2);
angle_bin = dets(I(idx), 3);
cur_det = dets(I(idx),:);
n_incluster = 1;
% check if the near point is within certain distance threshold of
% current element
for idx_nxt = idx+1:dets_num
if flag(I(idx_nxt))
continue
end
range_bin_diff = dets(I(idx_nxt), 1) - range_bin;
veloc_bin_diff = dets(I(idx_nxt), 2) - veloc_bin;
angle_bin_diff = dets(I(idx_nxt), 3) - angle_bin;
% wrap veloc_bin_diff around half Velocity FFT poiints
if abs(veloc_bin_diff) > N_vfft/2
veloc_bin_diff = N_vfft - abs(veloc_bin_diff);
end
if abs(range_bin_diff)<=dis_thrs(1) && abs(veloc_bin_diff/veloc_bin_norm)<=dis_thrs(2) ...
&& abs(angle_bin_diff)<=dis_thrs(3)
flag(I(idx_nxt)) = 1;
% update the location (range+angle) of center point
cur_det(1) = cur_det(1) + dets(I(idx_nxt), 1);
cur_det(3) = cur_det(3) + dets(I(idx_nxt), 3);
n_incluster = n_incluster + 1;
end
end
% update the flag of current element, and add it to the det_clustering
flag(I(idx)) = 1;
cur_det(1) = round(cur_det(1)/n_incluster);
cur_det(3) = round(cur_det(3)/n_incluster);
cur_det(5) = rng_grid(cur_det(1));
cur_det(7) = agl_grid(cur_det(3));
dets_cluster = [dets_cluster; cur_det];
end
I'm getting error in 49th line
Error in clustering (line 49)
cur_det(7) = agl_grid(cur_det(3));
Please help me to find this......
  3 commentaires
Prapthi
Prapthi le 3 Fév 2023
agl_grid has the matrix of 1X8 double, and the value of cur_det(3) is 66
Dyuman Joshi
Dyuman Joshi le 3 Fév 2023
How can you call the 66th element of a matrix which only has 8 elements?
I suggest you can your code again and verify it is according to what you want to do.

Connectez-vous pour commenter.

Réponses (1)

Swaraj
Swaraj le 10 Fév 2023
To handle this error, you should better add proper checks as the function is getting agl_grid as input.
For eg. For the statement : cur_det(7) = agl_grid(cur_det(3));
You can add following conditions.
if cur_det(3) <= length(agl_grid)
cur_det(7) = agl_grid(cur_det(3));
else
% Add some code to handle this case
end

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by