Okay, I wrote a function that will do this for you. While I was attempting to pull the data from the files you supplied "Company1.mat, Company2.mat and TimeStamp.mat" I didn't really understand what I received. Each file had 2 columns, but these columns were identical to one another. I expected to see two columns, one with a timestamp and the other with a value. So, instead, I ran this function using the data you supplied originally.
The catch here is that you have to supply the data to this function in a particular way. The input requires each company's information to be contained within one giant matrix with the timestamp first and the value second. It also requires you pass to it the timestamps you wish to get everything at. If you can't figure out how to do these two steps then we can go into that, but I think you can get it fairly easily.
The function has two outputs: first, the new timestamps, and second, the values from each of the companies at those timestamps. If I were running this code on my data I would call it like this...
[newTimes,newData] = sortData(companies,DesiredTimeStamps);
where the newTimes and newData variables will be the function outputs and the companies and DesiredTimeStamps variables will be the function inputs.
Save the function to its own m-file so that you can call it that way. It is...
function [new_time,newData] = sortData(oldData,new_time)
newTime = zeros(length(oldData),1);
newTime(1:length(new_time))=new_time;
numCompany = length(oldData(1,:))/2;
newData = zeros(length(oldData),numCompany);
i = 1;
comp = 1;
while i < numCompany*2;
for k=1:length(newTime)
for j=1:length(oldData)
if newTime(k) == 0;
break
elseif newTime(k) == oldData(j,i);
newData(k,comp) = oldData(j,i);
break
end
end
end
i = i+2;
comp = comp+1;
end
newData = newData(any(newData,2),:);
new_time = new_time(any(new_time,2),:);
new_time=datestr(new_time,'HH:MM:SS PM');
Good luck. I hope this helps.