Friday, July 24, 2009

Matlab Functions Description Continued..

actxserver

Create a COM Automation server and return a COM object for the server's default interface

Syntax

  • h = actxserver (progid [, machinename])

Arguments

progid
This is a string that is the name of the control to instantiate. This string is provided by the control or server vendor and should be obtained from the vendor's documentation. For example, the progid for MATLAB is matlab.application.

machinename
This is the name of a remote machine on which the server is to be run. This argument is optional and is used only in environments that support Distributed Component Object Model (DCOM)

Description

Create a COM Automation server and return a COM object that represents the server's default interface. Local/Remote servers differ from controls in that they are run in a separate address space (and possibly on a separate machine) and are not part of the MATLAB process. Additionally, any user interface that they display will be in a separate window and will not be attached to the MATLAB process. Examples of local servers are Microsoft Excel and Microsoft Word. There is currently no support for events generated from automation servers.

Examples

Launch Microsoft Excel and make the main frame window visible:

  • e = actxserver ('Excel.Application')
    e =
    COM.excel.application
    set(e, 'Visible', 1);

Call the get method on the excel object to list all properties of the application:

  • get(e)
    ans =
    Application: [1x1 Interface.excel.application.Application]
    Creator: 'xlCreatorCode'
    Parent: [1x1 Interface.Excel.Application.Parent]
    Workbooks: [1x1 Interface.excel.application.Workbooks]
    UsableHeight: 666.7500
    .
    .

Create an interface:

  • eWorkbooks = get(e, 'Workbooks')
    eWorkbooks =
    Interface.excel.application.Workbooks

List all methods for that interface by calling invoke with just the handle argument:

  • invoke(eWorkbooks)
    ans =
    Add: 'handle Add(handle, [Optional]Variant)'
    Close: 'void Close(handle)'
    Item: 'handle Item(handle, Variant)'
    Open: 'handle Open(handle, string, [Optional]Variant)'
    OpenText: 'void OpenText(handle, string, [Optional]Variant)'

Invoke the Add method on workbooks to add a new workbook, also creating a new interface:

  • w = Add(eWorkbooks)
    w =
    Interface.Excel.Application.Workbooks.Add

Quit the application and delete the object:

  • Quit(e);
    delete(e);


addframe

Add a frame to an Audio Video Interleaved (AVI) file.

Syntax

  • aviobj = addframe(aviobj,frame)
    aviobj = addframe(aviobj,frame1,frame2,frame3,...)
    aviobj = addframe(aviobj,mov)
    aviobj = addframe(aviobj,h)

Description

aviobj = addframe(aviobj,frame) appends the data in frame to the AVI file identified by aviobj, which was created by a previous call to avifile. frame can be either an indexed image (m-by-n) or a truecolor image (m-by-n-by-3) of double or uint8 precision. If frame is not the first frame added to the AVI file, it must be consistent with the dimensions of the previous frames.

addframe returns a handle to the updated AVI file object, aviobj. For example, addframe updates the TotalFrames property of the AVI file object each time it adds a frame to the AVI file.

aviobj = addframe(aviobj,frame1,frame2,frame3,...) adds multiple frames to an AVI file.

aviobj = addframe(aviobj,mov) appends the frame(s) contained in the MATLAB movie, mov, to the AVI file, aviobj. MATLAB movies that store frames as indexed images use the colormap in the first frame as the colormap for the AVI file, unless the colormap has been previously set.

aviobj = addframe(aviobj,h) captures a frame from the figure or axis handle h, and appends this frame to the AVI file. addframe renders the figure into an offscreen array before appending it to the AVI file. This ensures that the figure is written correctly to the AVI file even if the figure is obscured on the screen by another window or screen saver.

    Note If an animation uses XOR graphics, you must use getframe to capture the graphics into a frame of a MATLAB movie. You can then add the frame to an AVI movie using the addframe syntax, aviobj = addframe(aviobj,mov). See the example for an illustration.

Example

This example calls addframe to add frames to the AVI file object, aviobj.

  • fig=figure;
    set(fig,'DoubleBuffer','on');
    set(gca,'xlim',[-80 80],'ylim',[-80 80],...
    'nextplot','replace','Visible','off')

    aviobj = avifile('example.avi')

    x = -pi:.1:pi;
    radius = 0:length(x);
    for i=1:length(x)
    h = patch(sin(x)*radius(i),cos(x)*radius(i),...
    [abs(cos(x(i))) 0 0]);
    set(h,'EraseMode','xor');
    frame = getframe(gca);
    aviobj = addframe(aviobj,frame);
    end

    aviobj = close(aviobj);

No comments:

Post a Comment