I have a file which I am trying to read and then sort by column A and then by column C. The text file is attached and has 3 columns. This is what I have tried but it will not let me use the sort function after reading it in this way:
function data = ResultsScript(filename) fid = fopen(filename); data = textscan(fid, '%s %f %f'); fclose(fid);end
Then I call this function and try to sort it using:
fileName = 'Example.txt';A = ResultsScript(fileName);sortrows(A,[1,3]);
Running this gives the following error message:
??? Index exceeds matrix dimensions.Error in ==> sortrows>sort_cell_back_to_front at 133 ndx = ndx(ind);Error in ==> sortrows at 90 ndx = sort_cell_back_to_front(x_sub, col);Error in ==> GetResults at 3sortrows(A,[1,3]);
Any help is greatly appreciated.
Best Answer