Constructor examples of the PLIST class


Parameters can be grouped together into parameter lists (plist).

Creating parameter lists from parameters
Creating parameter lists directly
Appending parameters to a parameter list
Finding parameters in a parameter list
Removing parameters from a parameter list
Setting parameters in a parameter list
Combining multiple parameter lists

Creating parameter lists from parameters.

The following code shows how to create a parameter list from individual parameters.

    >> p1 = param('a', 1);  % create first parameter
    >> p2 = param('b', specwin('Hanning', 100));  % create second parameter
    >> pl = plist([p1 p2])  % create parameter list
    ----------- plist 01 -----------
    n params: 2
    ---- param 1 ----
    key: A
    val: 1
    -----------------
    ---- param 2 ----
    key: B
    val: specwin
    -------- Hanning ------------

    alpha: 0
    psll: 31.5
    rov: 50
    nenbw: 1.5
    w3db: 1.4382
    flatness: -1.4236
    ws: 50
    ws2: 37.5
    win: 100

    -----------------------------


    -----------------
    --------------------------------

Creating parameter lists directly.

You can also create parameter lists directly using the following constructor format:

  >> pl = plist('a', 1, 'b', 'hello')
  ----------- plist 01 -----------
  n params: 2
  ---- param 1 ----
  key: A
  val: 1
  -----------------
  ---- param 2 ----
  key: B
  val: 'hello'
  -----------------
--------------------------------  

Appending parameters to a parameter list.

Additional parameters can be appended to an existing parameter list using the append method:

      >> pl  = append(pl, param('c', 3))  % append a third parameter
      ----------- plist 01 -----------
      n params: 3
      ---- param 1 ----
      key: A
      val: 1
      -----------------
      ---- param 2 ----
      key: B
      val: 'hello'
      -----------------
      ---- param 3 ----
      key: C
      val: 3
      -----------------
      --------------------------------
  

Finding parameters in a parameter list.

Accessing the contents of a plist can be achieved in two ways:

    >> p1  = pl.params(1);   % get the first parameter
    >> val = find(pl, 'b');  % get the second parameter

If the parameter name ('key') is known, then you can use the find method to directly retrieve the value of that parameter.


Removing parameters from a parameter list.

You can also remove parameters from a parameter list:

      >> pl = remove(pl, 2) % Remove the 2nd parameter in the list
      >> pl = remove(pl, 'a') % Remove the parameter with the key 'a'
  


Setting parameters in a parameter list.

You can also set parameters contained in a parameter list:

      >> pl = plist('a', 1, 'b', 'hello')
      >> pl = pset(pl, 'a', 5, 'b', 'ola');  % Change the values of the parameter with the keys 'a' and 'b'
  


Combining multiple parameter lists.

Parameter lists can be combined:

      >> pl = combine(pl1, pl2)
  
If pl1 and pl2 contain a parameter with the same key name, the output plist contains a parameter with that name but with the value from the first parameter list input.



©LTP Team