×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

matlab code

matlab code

matlab code

(OP)
Hi and thank you for considering this post.
I have 2 time series (MID1 and MID2). They have a table format with 2 rows each. The first row is the date and the second row is a value. Both time series don't have continuouse dates.

For example
MID1:
01.02.2010 - 34
04.02.2010 - 37
07.02.2010 - 60
08.02.2010 - 61

MID2:
31.01.2010 - 20
02.02.2010 - 30
04.02.2010 - 32
06.02.2010 - 41
07.02.2010 - 40

I want to compare the data row. If the time series of MID1 and MID2 have the same date (in the example the 04.02.2010 and 07.02.2010) the values in the value rows should be summarized. If the comparison don't find the same date, it should be considered just the value of MID1 or MID2.
in the case of the example like this:

total:
31.01.2010 - 20
01.02.2010 - 34
02.02.2010 - 30
04.02.2010 - 37 + 32 = 69
06.02.2010 - 41
07.02.2010 - 60 + 40 = 100
08.02.2010 - 61

I was thinking it could work with a double loop like this:

MID1 with 1st row (date) and 2nd row (value)
MID2 with 1st row (date) and 2nd row (value)

-------------
total=zeros(2709,1)
for i=1:2709
for ii=1:2709
if MID1.date(i)==MID2.date(ii)
total(i)= MID1.value+MID2.value
elseif MID1.date(i)~=MID2.date(ii)
total(i)=MID1.value
else MID2.date(i)~=MID1.date(ii)
total(i)=MID2.value

end
end
end
-------------

As I'm super weak in programming, it didn't work out well. Could you help me in solving the problem?

thanks a lot!
Replies continue below

Recommended for you

RE: matlab code

I'm afraid your logic is wrong. There is no guarantee that MID1 has the same number of values as MID2. You are assuming that MID1 has all of MID2's dates in it. I suggest you start with a small subset of your data, and print the results out.

Cheers

Greg Locock


New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close