×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

# 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!

### 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.

#### Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a partâ€™s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!