Create a boundary of real numbers in a two dimentional matrix consisting of nan and real numbers

1 次查看(过去 30 天)
I have the organized point cloud data measured by Lidar.
That data is two dimentinal matrix consisting of nan and real numbers.
I want to divide the data by clutering with real number boundary.
Does this algorithm exist in the past? Or Is there a code like that?
Finally, I want to separate the obstacles' information.
  2 个评论
익환 류
익환 류 2022-11-29
a = [nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 nan nan nan nan nan nan 0.5 0.5 0.5 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 nan nan nan nan nan nan 0.5 0.5 0.5 nan nan nan nan nan 0.5 0.5 0.5 nan nan nan 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 nan nan nan nan nan nan 0.5 0.5 0.5 nan nan nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan nan 0.5 0.5 0.5 nan nan nan 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan nan nan nan nan nan nan nan 0.5 nan nan nan nan;...
nan nan nan 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan;...
nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan nan];

请先登录,再进行评论。

回答(1 个)

Kartik
Kartik 2023-3-21
Hi,
Yes, there are several algorithms in MATLAB that you can use to cluster the Lidar data based on real number boundaries. One approach you can use is the 'k-means' clustering algorithm. Here's an example code to get you started:
% Replace NaN values with zeros
a(isnan(a)) = 0;
% Set the number of clusters you want to create
num_clusters = 2;
% Perform k-means clustering
[idx, C] = kmeans(a(:), num_clusters);
% Reshape the clustered data to its original shape
idx = reshape(idx, size(a));
This code uses k-means clustering to create two clusters from the Lidar data. The 'kmeans' function takes the flattened data '(a(:))' and the number of clusters as input and returns the cluster indices '(idx)' and the centroid values '(C)'. The 'reshape' function is used to reshape the clustered data to its original shape.
You can adjust the number of clusters to match your needs. Note that the clustering result might not be perfect, especially if the data has a lot of noise or if the clusters are not well-separated. You might need to experiment with different clustering algorithms and parameters to get the best result for your data.

类别

Help CenterFile Exchange 中查找有关 Cluster Analysis and Anomaly Detection 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by