"Chris " <calmich@calpoly.edu> wrote in message <i3s5v8$g5i$1@fred.mathworks.com>...
> Hello everyone and thank you in advance for reading,
>
> I'm kind of new to matlab... I've used it for a few things in the past, but now that I need to do some real data analysis, excel is no longer cutting it!
>
> Here is my problem:
>
> I have long lists of photometry data that I need to subtract from eachother. My data sets are 2 columns: value, time. (The time is in Julian date so it's a long number to a very precise decimal). What I need to do is be able to subtract values from different data sets that have the same time. However since not all data sets are equal sizes, I need to somehow tell matlab to search for equal times and subtract the corresponding values.
>
> Ie.
>
> example data: When I subtract I want to see
> X Y X  Y
> 1 , A 1 , A 0,A
> 5 , B 2 , B 3,B
> 3 , C 4 , D 14,D
> 18 , D 5 , E (nothing for C & E)
>
> Any suggestions? I feel this should be relatively simple... but I'm relatively bad at matlab so it canceled out and I'm stuck at square 1.
>
I'm going to assume you don't actually have letters as your subscripts. If you do: convert them to unique numbers.
%%%Here's your example with numbers as identifiers
%Data
Vals = [...
1 , 1700;
1 , 1700;
5 , 1299;
2 , 1299;
3 , 1339;
4 , 11299;
18, 11299;
5 , 17] ;
%Engine
[u,~,ix] = unique(Vals(:,2));.
my_d = accumarray(ix,Vals(:,1),[],@(x)sum(diff(x)));
%Display
[u,my_d]
%%%
