PCAP to .MAT (want to use PCAP in Examples)

14 views (last 30 days)
Abdullah Rasul
Abdullah Rasul on 11 Feb 2019
Answered: Paola Donis Noriega on 29 Oct 2025 at 14:11
i am currently using velodyne VLP16 and most of the work is done in PCAP file.
i have tried some matlab examples with PCAP file and they are really good but there are some examples that uses .mat file instead of pcap.
can any one help me in using PCAP in those examples or how can i convert PCAP to .mat or even how can i get .mat file using velodyne VLP16.
thanks,
  5 Comments
Akshay Gupta
Akshay Gupta on 13 Apr 2022
Hello, can we save above mentioned converted MATLAB file into pcap file again?
As I have transfromed the point from pcap file frame by frame and save it in matrix/ or matlab file.
But I need to convert it to pcap file again.
Please suggest the solution for this.
Thanks
Abdullah Rasul
Abdullah Rasul on 14 Apr 2022
Matlab does not allow much processing with PCAP files. It usually converts them to .mat files for the processing.
In my opinion, convert your points to the point cloud file as explained here: https://www.mathworks.com/help/vision/ref/pointcloud.html#d123e118474
This way you can use the point cloud for processing as well and this point cloud format is compatible with most of the hardware/software
Thanks.

Sign in to comment.

Answers (1)

Paola Donis Noriega
Paola Donis Noriega on 29 Oct 2025 at 14:11
Hi Abdullah,
You can read point clouds from a PCAP file and store them as an array of pointCloud objects. Then, you can save this array to a MAT file. For example:
% Create a reader object for the PCAP file.
veloReader = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');
% Preallocate an array to hold each point cloud frame.
numFrames = veloReader.NumberOfFrames;
ptCloudArr = repmat(pointCloud(zeros(0, 3)),numFrames,1);
for i = 1:numFrames
% Read each frame and store it in the array.
ptCloudArr(i) = readFrame(veloReader,i);
end
% Save the array of point clouds to a MAT file.
save("velodyneData.mat","ptCloudArr")
Note: MATLAB does not support writing point clouds to PCAP files. To export point clouds, you can use the pcwrite function to save each point cloud to a PLY or PCD file.

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!