MATLAB: Would MATLAB read the .txt file which contains a header and x,y,z columns, as a single column

textscan

I need to extract xyz data from my text files. However, textscan reads the data into a single column instead of three. Below is the description
FileID = fopen('A.txt','r');
T = textscan(FileID,'%s %f %f','HeaderLines',1,'Delimiter',',');
fclose(FileID);
x = T{1};
y = T{2};
z = T{3};
The text file is attached.

Best Answer

%s%f%f with delimiter comma is not even close to being accurate for the file you attached. There is not even a single comma in the file.
FileID = fopen('A.txt','rt');
T = cell2mat( textscan(FileID, '%f%f%f', 'headerlines', 14, 'TreatAsEmpty', 'No Data', 'CollectOutput', true) );
fclose(FileID);
X = 0 : 639; Y = 0 : 479;
T3 = reshape(T(:,3), 640, []);
surf(X, Y, T3.', 'edgecolor', 'none');
xlabel('x'); ylabel('y');
You might prefer to enhance the code to read the 640 and 480 sizes from line 3 or 4 or 9 of the data.
Note: there is available code to read the ZYGO binary format.