If someone has an easy way to do it, please post. Below is how I was able to solve it. First read all the data from the excel using readtable. Then extracted the specific columns and rows I needed. Finally sorted using column 1 which should be in ascending order. It would have been great if I could do it using the excel filename instead of sorting by columns.
clear all;clc
% Specify the folder where the files live.
myFolder = 'C:\Users\myname\Documents\software\test';
% Check to make sure that folder actually exists. Warn user if it doesn't.
if ~isfolder(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s\nPlease specify a new folder.', myFolder);
uiwait(warndlg(errorMessage));
myFolder = uigetdir(); % Ask for a new one.
if myFolder == 0
% User clicked Cancel
return;
end
end
% Get a list of all files in the folder with the desired file name pattern.
M=[];
filePattern = fullfile(myFolder, '*.xlsm'); % Change to whatever pattern you need.
theFiles = dir(filePattern);
for k = 1 : length(theFiles)
baseFileName = theFiles(k).name;
fullFileName = fullfile(theFiles(k).folder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
T = readtable(fullFileName); % Read the entire excel file and stores it in a new matlab table [T]
M=[M;T(1:end,[1,9:11])]; % Extract specific rows and columns from table [T]
B = sortrows(M,1); % Sorts the extracted table [M]
plot(B.Timestamp,B.PSI) % Plots a table with specific columns
end