Friday, July 31, 2009

disp (serial)

Display serial port object summary information

Syntax

  • obj
    disp(obj)

Arguments


obj
A serial port object or an array of serial port objects.

Description

obj or disp(obj) displays summary information for obj.

Remarks

In addition to the syntax shown above, you can display summary information for obj by excluding the semicolon when:

  • Creating a serial port object
  • Configuring property values using the dot notation

Use the display summary to quickly view the communication settings, communication state information, and information associated with read and write operations.

Example

The following commands display summary information for the serial port object s.

  • s = serial('COM1')
    s.BaudRate = 300
    s


disp (timer)

Display information about timer object

Syntax

  • obj
    disp(obj)

Description

obj or disp(obj) displays summary information for timer object, obj.

If obj is an array of timer objects, disp outputs a table of summary information about the timer objects in the array.

In addition to the syntax shown above, you can display summary information for obj by excluding the semicolon when:

  • Creating a timer object, using the timer function
  • Configuring property values using the dot notation

Example

The following commands display summary information for the timer object t.

  • t = timer

    Timer Object: timer-1

    Timer Settings
    ExecutionMode: singleShot
    Period: 1
    BusyMode: drop
    Running: off

    Callbacks
    TimerFcn: []
    ErrorFcn: []
    StartFcn: []
    StopFcn: []

This example shows the summary information displayed for an array of timer objects, t_arr.

  • disp(t_arr)

    Timer Object Array

    Index: ExecutionMode: Period: TimerFcn: Name:
    1 singleShot 1 [] timer-1
    2 singleShot 1 [] timer-2



display

Overloaded method to display an object

Syntax

  • display(X)

Description

display(X) prints the value of a variable or expression, X. MATLAB calls display(X) when it interprets a variable or expression, X, that is not terminated by a semicolon. For example, sin(A) calls display, while sin(A); does not.

If X is an instance of a MATLAB class, then MATLAB calls the display method of that class, if such a method exists. If the class has no display method or if X is not an instance of a MATLAB class, then the MATLAB builtin display function is called.

Examples

A typical implementation of display calls disp to do most of the work and looks like this.

  • function display(X)
    if isequal(get(0,'FormatSpacing'),'compact')
    disp([inputname(1) ' =']);
    disp(X)
    else
    disp(' ')
    disp([inputname(1) ' =']);
    disp(' ');
    disp(X)
    end

The expression magic(3), with no terminating semicolon, calls this function as display(magic(3)).

  • magic(3)

    ans =

    8 1 6
    3 5 7
    4 9 2

As an example of a class display method, the function below implements the display method for objects of the MATLAB class, polynom.

  • function display(p)
    % POLYNOM/DISPLAY Command window display of a polynom
    disp(' ');
    disp([inputname(1),' = '])
    disp(' ');
    disp([' ' char(p)])
    disp(' ');

The statement

  • p = polynom([1 0 -2 -5])

creates a polynom object. Since the statement is not terminated with a semicolon, the MATLAB interpreter calls display(p), resulting in the output

  • p =

    x^3 - 2*x - 5

No comments:

Post a Comment