MATLAB: Dealing with string values

importstringstext values

Hi, all. I am dealing with a large amount of data with three columns, id, x, y.
While the ids are numeric, they need to be treated as text, for example some are 094567 and I cannot have MatLab stripping the leading 0 and making it 94567, which seems to happen with importdata(_____,'\t')
Is there a command that will treat these more appropriately?
Thanks,
-Clay

Best Answer

Here's one way:
clc;
numRows = 10;
m = randi(999999, numRows, 1) % Sample data
charm = sprintf('%6.6d', m) % Convert to 1-D character array.
charm = reshape(charm, [6, numRows]) % Back to 2D
charm = charm'