Main Content

merge

Merge two or more labeled signal sets

Description

example

lssnew = merge(lss1,...,lssN) merges N labeled signal set objects, lss1,...,lssN, and returns a labeled signal set lssnew containing all the members and label values of the input sets.

Examples

collapse all

Load a labeled signal set containing recordings of whale songs. Display the names of the set's members and a summary of its label definitions.

load whales

getMemberNames(lss)
ans = 2x1 string
    "Member{1}"
    "Member{2}"

labelDefinitionsSummary(lss)
ans=3×9 table
      LabelName        LabelType     LabelDataType     Categories     ValidationFunction    DefaultValue             Sublabels             Tag            Description         
    ______________    ___________    _____________    ____________    __________________    ____________    ___________________________    ___    ____________________________

    "WhaleType"       "attribute"    "categorical"    {3x1 string}       {["N/A"   ]}       {0x0 double}    {0x0 double               }    ""     "Whale type"                
    "MoanRegions"     "roi"          "logical"        {["N/A"   ]}       {0x0 double}       {0x0 double}    {0x0 double               }    ""     "Regions where moans occur" 
    "TrillRegions"    "roi"          "logical"        {["N/A"   ]}       {0x0 double}       {0x0 double}    {1x1 signalLabelDefinition}    ""     "Regions where trills occur"

Create a new signal set with the same data source, time information, and labels as lss. Remove the first member of the new set and change the name of the remaining one. Display the names of the new set's members.

newlss = copy(lss);

removeMembers(newlss,1)
setMemberNames(newlss,"YoungOne")

getMemberNames(newlss)
ans = 
"YoungOne"

Create a label definition that specifies whether a signal corresponds to a calf or to an adult whale. Add the definition to the new labeled signal set and label the member. Remove the label that specifies the moan regions. Display a summary of the new member's label definitions

calf = signalLabelDefinition('Calf','LabeldataType','logical','DefaultValue',false, ...
    'Description','Is the specimen a calf, or an adult?');

addLabelDefinitions(newlss,calf)
setLabelValue(newlss,1,"Calf",true)

removeLabelDefinition(newlss,"MoanRegions")
labelDefinitionsSummary(newlss)
ans=3×9 table
      LabelName        LabelType     LabelDataType     Categories     ValidationFunction    DefaultValue             Sublabels             Tag                 Description              
    ______________    ___________    _____________    ____________    __________________    ____________    ___________________________    ___    ______________________________________

    "WhaleType"       "attribute"    "categorical"    {3x1 string}       {["N/A"   ]}       {0x0 double}    {0x0 double               }    ""     "Whale type"                          
    "TrillRegions"    "roi"          "logical"        {["N/A"   ]}       {0x0 double}       {0x0 double}    {1x1 signalLabelDefinition}    ""     "Regions where trills occur"          
    "Calf"            "attribute"    "logical"        {["N/A"   ]}       {0x0 double}       {[       0]}    {0x0 double               }    ""     "Is the specimen a calf, or an adult?"

Merge the two labeled signal sets. Verify that the merged set contains the members, definitions, and labels of the original sets.

lssmerge = merge(lss,newlss);

getMemberNames(lssmerge)
ans = 3x1 string
    "Member{1}"
    "Member{2}"
    "YoungOne"

labelDefinitionsSummary(lssmerge)
ans=4×9 table
      LabelName        LabelType     LabelDataType     Categories     ValidationFunction    DefaultValue             Sublabels             Tag                 Description              
    ______________    ___________    _____________    ____________    __________________    ____________    ___________________________    ___    ______________________________________

    "WhaleType"       "attribute"    "categorical"    {3x1 string}       {["N/A"   ]}       {0x0 double}    {0x0 double               }    ""     "Whale type"                          
    "MoanRegions"     "roi"          "logical"        {["N/A"   ]}       {0x0 double}       {0x0 double}    {0x0 double               }    ""     "Regions where moans occur"           
    "TrillRegions"    "roi"          "logical"        {["N/A"   ]}       {0x0 double}       {0x0 double}    {1x1 signalLabelDefinition}    ""     "Regions where trills occur"          
    "Calf"            "attribute"    "logical"        {["N/A"   ]}       {0x0 double}       {[       0]}    {0x0 double               }    ""     "Is the specimen a calf, or an adult?"

Input Arguments

collapse all

Input labeled signal sets, specified as labeledSignalSet objects. All input sets must have the same time information settings and data source type.

Output Arguments

collapse all

Merged labeled signal set, returned as a labeledSignalSet object. The set lssnew contains a signal source, label definitions, and label values that are independent of those in the input labeled signal sets.

  • Changing any of the input labeled signal sets does not affect the merged labeled signal set.

  • Changing the merged labeled signal set does not affect any of the input labeled signal sets.

Introduced in R2020a