Date and time range picker from user

30 次查看(过去 30 天)
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

回答(1 个)

Rik
Rik 2023-5-23
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.

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by