Constructor examples of the SMODEL class


Copy a symbolic model object
Construct an empty symbolic model object
Construct an empty symbolic model object with the size zero
Construct a symbolic model object by loading the object from a file
Construct a simple example
Construct an LTPDA object from a parameter list object (PLIST)

A simple example

The following example shows you how to create a symbolic model.

>> s = smodel('a.*x.^2+b.*x+c');

You define with the command above the symbolic model. Please take care that each symbolic can represent a vector/matrix of numbers. This mean that you should use the array operators like '.*' or '.+' or ... and not the matrix operators like '*' or '^' or ....

Now, it is necessary to define the parameters with their default values

>> s.setParams({'a', 'b', 'c'}, {1 2 3})
   ---- symbolic model 1 ----
          name: None
          expr: a.*x.^2+b.*x+c
        params: {'a', 'b', 'c'}
        values: {1, 2, 3}
          xvar: 
         xvals: []
        xunits: []
        yunits: []
   description: 
          UUID: 7a084750-89c2-47f0-8c6b-65e9079bf6b3
   --------------------------

Finally it is necessary to set the 'x' variable and the values.

>> s.setXvar('x')
   ---- symbolic model 1 ----
          name: None
          expr: a.*x.^2+b.*x+c
        params: {'a', 'b', 'c'}
        values: {1, 2, 3}
          xvar: x
         xvals: []
        xunits: []
        yunits: []
   description: 
          UUID: ca9276b0-cc97-4001-9135-00c6799ec8b1
   --------------------------

>> s.setXvals(-100:100)
   ---- symbolic model 1 ----
          name: None
          expr: a.*x.^2+b.*x+c
        params: {'a', 'b', 'c'}
        values: {1, 2, 3}
          xvar: x
         xvals: [-100 -99 -98 -97 -96 -95 -94 -93 -92 -91 -90 -89 -88 -87 -86 ...]
        xunits: []
        yunits: []
   description: 
          UUID: f43e2f9b-3fb6-4e3c-92ba-7cba31c6a6c3
   --------------------------

After all steps above it is possible to plot the model.

>> s.setXunits('s');
>> s.setYunits('V');
>> s.setName('Just a test');
>> iplot(s.eval)
Plot of symbolic model



©LTP Team