Programming and Data Types    

The Polynom subsref Method

Suppose the design of the polynom class specifies that a subscripted reference to a polynom object causes the polynomial to be evaluated with the value of the independent variable equal to the subscript. That is, for a polynom object p,

the following subscripted expression returns the value of the polynomial at
x = 3 and x = 4.

subsref Implementation Details

This implementation takes advantage of the char method already defined in the polynom class to produce an expression that can then be evaluated.

Once the polynomial expression has been generated by the char method, the strrep function is used to swap the passed in value for the character x. The eval function then evaluates the expression and returns the value in the output argument.


  The Polynom display Method Overloading Arithmetic Operators for polynom