MATLAB: How to load a .dat (comma-separated) .dat How can I read a file in .dat format, which has three commas in each row and only the second is a separator? The others are decimal separators. Maybe I do not explain my problem sufficiently, so I attach the mentioned file. Best Answer v=importdata('1.dat')w=v(1:2:end)out=regexprep(w,'(?<=\S+,\S+),', ' ') Related SolutionsMATLAB: Reding csv file which contains numbers and strings Try importdata but it's not absolutely guaranteed. With the regular numeric format it should be able to figure it out.But, if it can't successfully read the first column as a text header then textscan or fscanf are your friends.... MATLAB: Split comma-separated rows into separate columns >> Z = cellfun(@(c)cellfun(@(v)v(:),c,'uni',0),x,'uni',0)Z = {1x1 cell}>> Z{1}{1}ans = 2 1 2 3Although your code would be a lot simpler if you did not use nested cell arrays in the first place. Related QuestionGenerate a comma-separated list from a numeric arrayArray of structures to cell array via comma-separated listHow to import .csv data into guide
Best Answer