Date and time range picker from user

29 views (last 30 days)
Luca D'Angelo
Luca D'Angelo on 23 May 2023
Answered: Rik on 23 May 2023
Hi all,
I'm writing a script (not with App designer) and I want to creating a gui where it is asked to insert beginning and ending date ("dd-MM-yyyy") and time ("hh:mm") of a specific event (like collection of blank data).
I like a lot the uidatepicker and I'd like to use an interface like that one.
So I wrote this:
fig = uifigure('Position',[500 500 375 280]);
dstart = uidatepicker(fig,'Position',[18 225 150 22]);
dend = uidatepicker(fig,'Position',[18 200 150 22]);
But:
  • I don't know how to ask for the time too;
  • I don't know how to "record" the data and to use them (like with the "timerange" function) since I don't understand when dstart.Value actually write the data: is there a way to create a button like "ok" or "acquire" in order to write the input?
  • I don't know which would be the command to close the gui
Thank you for your reply.
Luca

Answers (1)

Rik
Rik on 23 May 2023
You might be interested in this example. You can easilly create an 'ok' button that will retrieve the set dates and times and closes the GUI.
Either close(fig) or delete(fig) will close the uifigure.
Note that you should consider using functions instead of script for anything you plan on using after next week. Functions provide an interface you can document and have their own workspace which is independent from the rest of the environment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!