Thank you so much for your reply someone! I had actually been using the intersect function for something else, I hadn't thought of using it for this problem. It works fine now. Thanks again! :)
"someone" wrote in message <firstname.lastname@example.org>... > "Anna " <email@example.com> wrote in message <firstname.lastname@example.org>... > > Hi everyone, > > > > I have two data sets which have different time stamps relative to each other. I am trying to 'align' the time stamps so that I can compare different variables in one datset with variables in the other dataset. The data sets are measurements with start and end times and I need the start and end times to be the same in both data sets so that I can compare them. Currently, one of the data sets has a much longer matrix than the other and preceeds and exceeds the other data sets' 'start' and 'end' times by a large margin. > > > > The larger matrix, 'a', has a start time i.e. first data entry of 30000 (not the exact value) and an end time i.e. last data entry of 55000 (not the exact value). The second, shorter data, 'b', set has the start time 36000 and the end time 54000. So I want to use the start and end times in a that correspond with those in b. I hope that makes sense! > > > > I have tried to use the following method but without success: > > --------------------------------- > > >>a = [30000:55000]; > > >>b = [36000:54000]; > > >>a_start = 36000; > > >>a_end = 54000; > > >>c = a(a_start:a_end) > > Index exceeds matrix dimensions > > --------------------------------- > > I'm quite new to Matlab and I would really appreciate some advice! > > > > Thanks > > % You have the right idea, but the problem is: > a(1) = 30000; > a(25001) = 55000; % I THINK I did the math right > > % so, the length of a is 25001, not 55000. > % Same type of reasoning for b. > > % When you say: > c = a(36000:54000) > % those entries in a do not exist (a is not length 54000). > % you mean something like: > c = a(6001:24001) > > % To avoid the tricky math, try something like: > doc intersect > > % In your case, > c= intersect(a,b) > should do the trick.