Batch conversion from mat file to pcd file

2 vues (au cours des 30 derniers jours)
Vu Minh
Vu Minh le 18 Juil 2022
Commenté : Walter Roberson le 19 Juil 2022
Hello. I have around 1800 mat file in the discontinous order like 1,2,4,7,8, etc. I already found a code to load all the mat file but I can not do the batch conversion from mat to pcd file. Can anyone help me with this? Thanks in advance!

Réponse acceptée

Walter Roberson
Walter Roberson le 18 Juil 2022
inputdir = 'Appropriate mat folder name goes here';
outputdir = 'Appropriate pcd folder name goes here';
if ~exist(inputdir, 'dir'); error('Input directory %s does not exist', inputdir); end
if ~exist(outputdir, 'dir'); mkdir(outputdir); end
dinfo = dir( fullfile(inputdir, '*.mat') );
filenames = fullfile({dinfo.folder}, {dinfo.name});
for K = 1 : length(filenames)
thisfile = filenames{K};
[~, basename, ~] = fileparts(thisfile);
outname = fullfile(outputdir, [basename '.pcd']);
Convert_mat_to_pcd(thisfile, outname);
end
Given appropriate code Convert_mat_to_pcd that uses the first parameter as the name of the input .mat file and uses the second parameter as the (fully qualified) output file name.
  7 commentaires
Vu Minh
Vu Minh le 19 Juil 2022
Thank you sir for your valueable advice. I got this now. Anyway the function for loading mat file should be "importdata" instead of "load".
Walter Roberson
Walter Roberson le 19 Juil 2022
No, the function for loading mat files should be load(). importdata() has a lot of overhead and can return unexpected results.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Read, Write, and Modify Image 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