How To Get Data From ValueChangedFcn in an Uidatepicker?
Show older comments
Hi, Community,
I have a problem to get data value from ValueChangedFcn properties... So i have functions below :
dating_timing_original = datetime vector...
cals = datetime(dating_timing_original, 'InputFormat', 'yyyy-MM-dd HH:mm:ss', 'Format', 'yyyy-MM-dd');
mydateapp(cals);
function ff = mydateapp(cals)
fig = uifigure('Position',[200 300 400 300]);
d = uidatepicker(fig,'DisplayFormat','yyyy-MM-dd',...
'Position',[130 190 152 30],...
'Value',min(cals),...
'Limits', [min(cals) max(cals)],...
'ValueChangedFcn', @datechange);
outs = d.ValueChangedFcn;
ff = outs;
function [outs] = datechange(src, event)
% fig2 = uifigure('Position',[130 190 150 22]);
lastdate = char(event.PreviousValue);
newdate = char(event.Value);
if newdate == lastdate
newdate = lastdate
end
% msg = ['Change date from ' lastdate ' to ' newdate '?'];
% Confirm new date
% selection = uiconfirm(fig2,msg,'Confirm Date');
outs = string(datetime(newdate, 'Format', 'yyyy-MM-dd HH:mm:ss'));
src.ValueChangedFcn = outs;
How to get 'ValueChangedFcn' data as an output of mydateapp(cals) function so i can get the value of datetime data as result of clicked calendar (uidatepicker).... Thank you everyone...
2 Comments
Geoff Hayes
on 1 Apr 2022
@Tyann Hardyn - can you add some more details on how the above code is to be used? Do you have a GUI (if so, was it designed with App Designer, GUIDE, programmatically?) or are you using a script or function to do some work?
Tyann Hardyn
on 2 Apr 2022
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!