Reputation: 473
I have a n-lines file with this structure (X Y coordinates):
100 20
101 29
102 22
102 33
X Y
I am trying to read it and split the coordinates to 2 different cells using textscan
(so I will get one cell for the X
coordinates and the 2nd for the Y
coordinates) using the script below.
clear;
fileID = fopen("E:/temp.txt");
formatSpec = '%d';
C = textscan(fileID,formatSpec,'Delimiter',' ');
fclose(fileID);
As it does not work help will be appreciated.
Upvotes: 2
Views: 52
Reputation: 76
Try
clear;
fileID = fopen("E:/temp.txt");
formatSpec = '%d%d';
C = textscan(fileID,formatSpec);
fclose(fileID);
Xcoord=C(:, 1);
YCoord=C(:, 2);
Upvotes: 1