UICalendar User Interface

Using UICalendar in Standalone Mode

You can use the UICalendar user interface in standalone mode to look up any date. To use the standalone mode:

  1. Type the following command to open the UICalendar GUI:


    The UICalendar interface is displayed:

  2. Click the date and year controls to locate any date.

Using UICalendar with an Application

You can use the UICalendar user interface with an application to look up any date. To use the UICalendar graphical interface with an application, use the following command:

uicalendar('PARAM1', VALUE1, 'PARAM2', VALUE2', ...)

For more information, see uicalendar.

Example of Using UICalendar with an Application

The UICalendar example creates a function that displays a user interface that lets you select a date from the UICalendar user interface and fill in a text field with that date.

  1. Create a figure.

    function uicalendarGUIExample
    f = figure('Name', 'uicalendarGUIExample');

  2. Add a text control field.

    dateTextHandle = uicontrol(f, 'Style', 'Text', ...
    'String', 'Date:', ...
    'Horizontalalignment', 'left', ...
    'Position', [100 200 50 20]);

  3. Add an uicontrol editable text field to display the selected date.

    dateEditBoxHandle = uicontrol(f, 'Style', 'Edit', ...  
    'Position', [140 200 100 20], ...  
    'BackgroundColor', 'w');

  4. Create a push button that startups the UICalendar.

    calendarButtonHandle = uicontrol(f, 'Style', 'PushButton', ...  
    'String', 'Select a single date', ...  
    'Position', [275 200 200 20], ...  
    'callback', @pushbutton_cb);

  5. To start up UICalendar, create a nested function (callback function) for the push button.

    function pushbutton_cb(hcbo, eventStruct)  
    % Create a UICALENDAR with the following properties:  
    % 1) Highlight weekend dates.  
    % 2) Only allow a single date to be selected at a time.  
    % 3) Send the selected date to the edit box uicontrol.  
    uicalendar('Weekend', [1 0 0 0 0 0 1], ...  
    'SelectionType', 1, ...  
    'DestinationUI', dateEditBoxHandle);

  6. Run the function uicalendarGUIExample to display the application interface:

  7. Click Select a single date to display the UICalendar user interface:

  8. Select a date and click OK to display the date in the text field:

See Also

| |

Related Examples

Was this topic helpful?