Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Merging Data
Replies: 1   Last Post: Feb 20, 2013 2:43 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Peter Perkins

Posts: 111
Registered: 8/12/11
Re: Merging Data
Posted: Feb 20, 2013 2:43 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

If you are using dataset arrays from the Statistics Toolbox, then I
think you want to do an outer join, using lon and lat as the key variables:

>> d3 = join(d1,d2,'Type','outer','Keys',{'lon' 'lat'},'MergeKeys',true)
d3 =
lon lat x1 x2
-180 90 0.47757384 0.178041266
-179.9 90 0.064759965 NaN
-179.8 90 0.729165056 NaN
-179.7 90 0.995015965 NaN
-179.6 90 0.970115665 NaN
-179.5 90 0.299555583 NaN
-179.4 90 0.261979872 NaN
-179.3 90 0.786517018 NaN
-179.2 90 0.628835449 NaN
-179.1 90 0.068506162 NaN
-179 90 0.154043527 0.349792078
-178 90 NaN 0.463907651
-177 90 NaN 0.511614411
-176 90 NaN 0.0729513
-175 90 NaN 0.713571611
-174 90 NaN 0.009430638
-173 90 NaN 0.528177669
-172 90 NaN 0.747954951
-171 90 NaN 0.731053422
-170 90 NaN 0.24842768


BUT: using floating point values as keys is equivalent to testing exact
equality in floating point, which is fraught with problems.


On 2/20/2013 12:02 PM, Arghya wrote:
> Hi,
> I am new user of Matlab and need some help to merge two dataset into
> one. I am pasting below the top 12 lines of the each dataset I have and
> what I expect to do with them. Any help is appreciated.
>
> dataset1 dataset2
> lon lat x1 lon lat x2
> -180 90 0.47757384 -180 90 0.178041266
> -179.9 90 0.064759965 -179 90 0.349792078
> -179.8 90 0.729165056 -178 90 0.463907651
> -179.7 90 0.995015965 -177 90 0.511614411
> -179.6 90 0.970115665 -176 90 0.0729513
> -179.5 90 0.299555583 -175 90 0.713571611
> -179.4 90 0.261979872 -174 90 0.009430638
> -179.3 90 0.786517018 -173 90 0.528177669
> -179.2 90 0.628835449 -172 90 0.747954951
> -179.1 90 0.068506162 -171 90 0.731053422
> -179 90 0.154043527 -170 90 0.24842768
>
> FinalDataset: <<- that I intend to make after merging dataset 1 and
> dataset 2
> lon lat x1 x2
> -180 90 0.47757384 0.178041266
> -179.9 90 0.064759965 NaN
> -179.8 90 0.729165056 NaN
> -179.7 90 0.995015965 NaN
> -179.6 90 0.970115665 NaN
> -179.5 90 0.299555583 NaN
> -179.4 90 0.261979872 NaN
> -179.3 90 0.786517018 NaN
> -179.2 90 0.628835449 NaN
> -179.1 90 0.068506162 NaN
> -179 90 0.154043527 0.349792078
>
> Thanks in advance!





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.