Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Simple matching problem? Need help!

Subject: Simple matching problem? Need help!

From: Chris

Date: 10 Aug, 2010 18:32:08

Message: 1 of 4

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.


                                                    

Subject: Simple matching problem? Need help!

From: Chris

Date: 10 Aug, 2010 18:49:04

Message: 2 of 4

"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.
>
>
>
Looks like the formatting didn't preserve.... to see the example more clearly look at the original formatting

Subject: Simple matching problem? Need help!

From: Matt Fig

Date: 10 Aug, 2010 18:59:08

Message: 3 of 4

Just to be clear, is your data in a cell array or a structure or what?

Subject: Simple matching problem? Need help!

From: Sean

Date: 10 Aug, 2010 19:06:21

Message: 4 of 4

"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]

%%%

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us