Date popup calendar for MATLAB for gui

Does anyone know a way to display a pop-up date picker calendar in the MATLAB GUI? I know that the financial toolbox has a uicalendar function, but unfortunately I do not have it.

I have a hunch that for this I will have to use Java or another language that I know nothing about.

I am looking for something similar to this: alt text
(source: welie.com )

which will return a date string after the user selects a date.

+6
user-interface matlab calendar datepicker
source share
4 answers

I do not have much time for a more complete answer, unfortunately, but I would try uitable to create a table and define a CellSelectionCallback to get the date.

Here is a bit to get you started:

 dates = calendar; dates(~any(dates,2),:) = []; fh = figure; uh = uitable('parent',fh,'data',dates,'ColumnWidth',repmat({20},1,7),... 'ColumnName',{'S','M','T','W','T','F','S'}); 
+4
source share

Here are two approaches that will give you a professional looking calendar component in Matlab without the hassle of programming.

  1. Use a Java calendar component (for example, one of these or these ). Once you load the appropriate Java class or Jar file, add it to the static path to the Java classes (use the edit('classpath.txt') command edit('classpath.txt') from the Matlab command line). Finally, use the built-in javacomponent function to place the component in the Matlab image window.

  2. If you use Windows, you can embed any available Active-X calendar control. Use the built-in actxcontrolselect function to select your favorite calendar control (for example, Microsoft Office "Calendar Control 11.0" - MSCAL.Calendar.7 - which is automatically installed with Office 2003; or "Microsoft Date and Time Picker Control 6.0" - MSComCtl2. DTPicker. 2 or ...). Then use the actxcontrol function to place the component in the Matlab shape window.

  3. Matlab has some pretty useful built-in calendar controls (date picker) - today I published an article about them.

+7
source share

I would start with the calendar () function, which displays a matrix containing a calendar for any month. I assume that you could combine this with the user interface to get a specific date?

The following code is really ugly, but may help you get started ...

  WINDOW_WIDTH = 300; WINDOW_HEIGHT = 200; f= figure('Position',[300 300 WINDOW_WIDTH WINDOW_HEIGHT]); NB_ROWS = 6; NB_COLS = 7; width = round(WINDOW_WIDTH/NB_COLS); height = round(WINDOW_HEIGHT/NB_ROWS); buttons = nan(NB_ROWS,NB_COLS); dates = calendar(); for row = 1:NB_ROWS for col = 1:NB_COLS if dates(row,col) == 0 mydate = ''; else mydate = sprintf('%i', dates(row,col)); end buttons(row,col) = uicontrol('Style', 'PushButton', ... 'String', mydate, ... 'Position', [(col-1)*width (NB_ROWS - row)*height width height]); end end 
+4
source share

The uigetdate function in Mathworks File Exchange is also a good solution:

http://www.mathworks.com/matlabcentral/fileexchange/8313-uigetdate

+4
source share

All Articles