Matlab Read V3D Txt

From Software Product Documentation
Jump to navigation Jump to search

The following sample code can be used to read a text file exported from Visual3D into Matlab.

This assumes the user exported the headers. The numerical values are stored in numericData and the headers are stored in headerData.

Exmaple

% ---------------------------------------------------
% Read Visual3D Text File
% ---------------------------------------------------

filename = 'C:\Users\Documents\Support\Test.txt';

numericData = dlmread(filename,'\t',5,1);

[ rows , columns ] = size(numericData);
headerCount = ( columns + 1 )* 5; 

fileID = fopen(filename);
importHeaders = textscan(fileID,'%s',headerCount,'Delimiter','\t');
fclose(fileID);

clearvars filename fileID;

headerData = cell(5,columns);
start=2; 
for i=1:5
    stop= (start + columns) - 1;
    headerData(i,:) = transpose(importHeaders{1,1}(start:stop));
    start = stop+2;
end

clearvars rows columns start stop i headerCount importHeaders;
Retrieved from ""