MATLAB: A fined commute program

commuteexcelgui

I would like to create a fine program that meets the following conditions:
1.The menu command first displays 6 names on the screen and then saves the time the checkbox(1~6) was selected.
2. When the checkbox(1~6) selected, a message box will pop up and show the tradiness fine.
3.(However, it should show that there is no penalty at the time of attendance before 10:10.)
4.It will reduce the fine every 30minutes from the moment the user pass 7:00p.m.
5. If you click on the checkbox(7~12), a message box will pop up and show the final fine for the day.
6. And automatically save the time when the user click the check box as Excel.
7. After one day, it will reset itself. (However, the value saved in Excel will not be erased and will accumulate per name.)
Here is the code that I wrote using the gui.
% --- Executes on button press in checkbox1.
function checkbox1_Callback(hObject, eventdata, handles)
% hObject handle to checkbox1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB

% handles structure with handles and user data (see GUIDATA)

if(get(handles.checkbox1,'Value'))
t1 = clock;
DataString1 = datestr(t1);
fine1 = floor(((t1(4)-10)*60 + t1(5)-30)/10)*1000;
if fine1>0;
f = msgbox({'Arrival time is.',DataString1, 'Fine is.',num2str(fine1)});
else
f=msgbox({'Arrival time is.',DataString1, 'There is no fine.'})
end
end
filename = 'name1.xlsx';
xlRange='A1';
xlswrite('name1.xlsx',fine1,xlRange);
% --- Executes on button press in checkbox7.
function checkbox7_Callback(hObject, eventdata, handles)
% hObject handle to checkbox7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(get(handles.checkbox7,'Value'))
t7 = clock;
DataString7 = datestr(t7);
minusfine1 = floor(((t7(4)-19)*60 + t7(5))/30)*1000;
name1fine = fine1-minusfine1;
if (name1fine)>0
f = msgbox({'Departure time is .',DataString7,'Today's total fine is.', num2str(name1fine)});
else
f=msgbox({'Departure time is .', DataString7, 'There is no total fine.'})
end
end
filename = 'name1.xlsx';
xlRange='B1';
xlswrite('name1.xlsx',minusfine1,xlRange);
xlRange='C1';
xlswrite('name1.xlsx',name1fine,xlRange);
To explain it, press the checkbox (checkbox1) to save the time, calculate it and impose a fine.
You can also press the checkbox next to it to show the deduction value and show the total fine for that day.
In the code below, I want to save the value of the penalty received when checkbox1 is displayed, the penalty deduction value received when checkbox7 is displayed, and the total penalty value in Excel.
Each time you click on the above three values ​​once a day, it will be saved in Excel.
I also want to put those three saved values ​​in one file.
However, Excel is not saved.
I do not know what to do anymore, what is wrong.
It's not easy because you only studied with books …
I'm eager for your help.
Attached file added.

Best Answer

Set a breakpoint at the xlswrite() line and see if the program stops there. If it doesn't use standard debugging practices to figure out why it doesn't.
If you STILL can't figure out why it's not reaching the xlswrite() line, or if it executes that line but still does not create a workbook, then attach both your m-file and .fig file, and any other files that are needed so we can run your program and reproduce the problem.