MATLAB: Separate one column in an imported matrix

importing excel dataload

Hello,
Basically, I have a table where the last column really has several values. The number of these values differ. What I would like is to import the data so that it is all in a matrix and instead of one column showing points, you have a subsequent series of columns from (point one) to (point n). It is fine to fill zeros so that every row has the same number of vectors. I attached a portion of my data sheet. MatLab tries to sum or multiply these values when importing; I took a first pass at trying to use textscan and splitcells and other things I saw on the forum but I cannot get it to run correctly. Anyone know the easiest way to do this? I said C=textscan(segments1,'%f') and got that the first input must be a valid file-id or non-empty character vector.

Best Answer

The way I'd do it:
t = readtable('test11_1.txt'); %import as table
t.PointIDs = rowfun(@(s) sscanf(s, '%f,', [1 Inf]), t, 'InputVariables', 'PointIDs', 'ExtractCellContent', true, 'OutputFormat', 'cell')
It's probably better to keep the data in a table rather than storing it in a matrix, particularly one padded with 0s.