MATLAB: AppDesigner,: Hi there, I am working on a user interface using AppDesigner. My app is a simple financial mathematics tool, it basically handles annuities and single amount investments.

appdesignerdatepicker

Now the problem i have is that my algorithm requires that the user inputs "transaction details" on the interface and presses a button that will then store those details that are to be used when another button is pressed. So button A is Confirm transaction and Button B calculates the balance on a certain date.
So from button A the data is to be stored in three seperate lists(or vectors) theres a transaction amount list, a date list and the type of transaction list. But now I am gettin an error when I store the dates I am not sure why: here is a snippet of the code where the error is;
I am new at Matlab , so I have not yet figure the syntax, please help
Button A callback
y = app.AmountEditField.Value;
zz = app.DropDown.Value;
ydate = app.DatePicker_2.Value;
selections = app.ButtonGroup_6.SelectedObject
if zz == "Deposit"
y =y;
if selections == app.OnceOffButton
app.additionalAmounts(end+1) = y;
app.additionalAmountDates(end+1) = app.DatePicker_2.Value; *****(error is here)*******
elseif selections == app.AnnuityAdvanceButton
app.annuityAmounts(end+1) = y;
app.annuityAmountsDates(end+1) = app.DatePicker_2.Value;
app.annuityAmountsPays(end+1) = app.TotalPayments.Value;

Best Answer

How have you initialized additionalAmountDates? It needs to be datetime for your code to work, but appears to be numeric (double).
Something like this works for me
properties (Access = private)
additionalAmountDates = datetime.empty% Description
end
Each date is successfilly added when I test it with the following code.
% Value changed function: DatePicker
function DatePickerValueChanged(app, event)
value = app.DatePicker2.Value;
app.additionalAmountDates(end+1) =value;
end