Extracting specific data for multiple mat files

Hello. I am having around 1800 mat files that are the output of Venlodyne lidar. I have converted all of them to the PCD format as well. So, I want to extract the specific data, which is determined by specific row or column, from those files. Please help me with this question. Thank you so much for your support!

2 件のコメント

Chunru
Chunru 2022 年 8 月 22 日
Attach some sample data.
Thanh
Thanh 2022 年 8 月 22 日
Sorry for not adding files. Here are some files for instance.

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

回答 (2 件)

Chunru
Chunru 2022 年 8 月 22 日

1 投票

fn = dir("save*.mat")
fn = 2×1 struct array with fields:
name folder date bytes isdir datenum
for i = 1:length(fn)
matobj{i} = matfile(fn(i).name)
matobj{i}.PCD % Then you can access to any portion of data and assign the results to a variable
end
matobj = 1×1 cell array
{1×1 matlab.io.MatFile}
ans =
pointCloud with properties: Location: [16×1808×3 double] Count: 28928 XLimits: [-10.5304 19.9285] YLimits: [-5.1332 9.1553] ZLimits: [-2.5690 5.3415] Color: [] Normal: [] Intensity: [16×1808 uint8]
matobj = 1×2 cell array
{1×1 matlab.io.MatFile} {1×1 matlab.io.MatFile}
ans =
pointCloud with properties: Location: [16×1808×3 double] Count: 28928 XLimits: [-10.5543 19.8885] YLimits: [-5.1543 9.2809] ZLimits: [-2.5587 5.3218] Color: [] Normal: [] Intensity: [16×1808 uint8]
Thanh
Thanh 2022 年 8 月 23 日
編集済み: Thanh 2022 年 8 月 23 日

1 投票

Thank you SIr for your answer. I tried to use the code to extract data of all mat files in column 1706 but it pops up another error "Index in position 2 exceeds array bounds. Index must not exceed 1." Can you help me with this error please? You can see my code adjustment here. Thank a lots!
fn = dir("save*.mat")
for i = 1:length(fn)
matobj{i} = matfile(fn(i).name)
dataPCD = matobj{i}.PCD % Then you can access to any portion of data and assign the results to a variable
Data = dataPCD(:,1706)
end

5 件のコメント

Chunru
Chunru 2022 年 8 月 23 日
What data you want to extract? dataPCD is an object of pointCloud. Which part of the data you want to extract?
pointCloud with properties:
Location: [16×1808×3 double]
Count: 28928
XLimits: [-10.5304 19.9285]
YLimits: [-5.1332 9.1553]
ZLimits: [-2.5690 5.3415]
Color: []
Normal: []
Intensity: [16×1808 uint8]
Thanh
Thanh 2022 年 8 月 23 日
編集済み: Thanh 2022 年 8 月 23 日
I want to extract the y-value of column 1706 of Location data. I tried with the following code but the ouput is not as same as in Location data which I manually picked from those files.
fn = dir("save*.mat")
for i = 1:length(fn)
matobj{i} = matfile(fn(i).name)
dataPCD = matobj{i}.PCD % Then you can access to any portion of data and assign the results to a variable
Data(:,i) = dataPCD.Location(:,1706)
end
Chunru
Chunru 2022 年 8 月 23 日
The location data has the following 3D format:
Location: [16×1808×3 double]
Which slice of data you want to extract? You might want to specify 3 indeces instead of 2.
Thanh
Thanh 2022 年 8 月 24 日
Thank you Sir so much! I have extracted the data
Chunru
Chunru 2022 年 8 月 24 日
Glad to know that.

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

カテゴリ

ヘルプ センター および File ExchangeLabeling, Segmentation, and Detection についてさらに検索

製品

リリース

R2022a

質問済み:

2022 年 8 月 22 日

コメント済み:

2022 年 8 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by