Just use csvread :
M = csvread('filename.csv'); pt_num = M(:,1); x = M(:,2); y = M(:,3);
You can also use textscan to get each column in an array of cells:
fid = fopen('filename.csv','r'); C = textscan(fid,'%d, %n, %n'); fclose(fid);
And there is fscanf , but you have to resize the array:
fid = fopen('filename.csv','r'); M = fscanf(fid,'%d, %f, %f') fclose(fid); M = reshape(M,3,[])';
Finally, dlmread , which works just like csvread :
M = dlmread('filename.csv',',');
source share