I have a 100 .dat files like the one in the left hand pane, which I need to import without headers and then sort rows.
ANSWER for doing it manually, file by file:
data=sortrows(data,2); #sort all columns of data via the 2nd col
fid=fopen('pole_2_TurbI_chamber_05_RSM.xy');
[x ~] = textscan (fid, '%f %f', 'HeaderLines', 4); # reads file correctly
fclose(fid);
v(:,1)=cell2mat(x(:,1)); # convert from cell to array
v(:,2)=cell2mat(x(:,2));
v=sortrows(v,2); # sort rows according to column 2
% fig
plot(v(:,1),-v(:,2),'ro');
How can I extend this to all the files in my directory? Perhaps giving each imported variable the file name... if possible. Regards,